Subject: [Boost-bugs] [Boost C++ Libraries] #4798: date_time: valgrind warnings via strings_from_facet.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-28 14:40:23
#4798: date_time: valgrind warnings via strings_from_facet.hpp
----------------------------------------------------+-----------------------
Reporter: Lars Immisch <lars.immisch@â¦> | Owner: az_sw_dude
Type: Patches | Status: new
Milestone: To Be Determined | Component: date_time
Version: Boost Development Trunk | Severity: Cosmetic
Keywords: valgrind |
----------------------------------------------------+-----------------------
On Ubuntu, with GNU libc6 (2.7-10ubuntu7), and a program that uses
`boost::date_time::time_input_facet< boost::posix_time::ptime,char>`
valgrind generates a warning:
{{{
==11026== Conditional jump or move depends on uninitialised value(s)
==11026== at 0x467C04B: __strftime_internal (strftime_l.c:574)
==11026== by 0x467DD4F: strftime_l (strftime_l.c:490)
==11026== by 0x456B420: std::__timepunct<char>::_M_put(char*, unsigned
int, char const*, tm const*) const (in /usr/lib/libstdc++.so.6.0.13)
==11026== by 0x452BB4C: std::time_put<char,
std::ostreambuf_iterator<char, std::char_traits<char> >
>::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >,
std::ios_base&, char, tm const*, char, char) const (in
/usr/lib/libstdc++.so.6.0.13)
==11026== by 0x452B0CF: std::time_put<char,
std::ostreambuf_iterator<char, std::char_traits<char> >
>::put(std::ostreambuf_iterator<char, std::char_traits<char> >,
std::ios_base&, char, tm const*, char const*, char const*) const (in
/usr/lib/libstdc++.so.6.0.13)
==11026== by 0x8430C83: std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >
boost::date_time::gather_month_strings<char>(std::locale const&, bool)
(strings_from_facet.hpp:58)
==11026== by 0x84310D9:
boost::date_time::format_date_parser<boost::gregorian::date,
char>::format_date_parser(std::string const&, std::locale const&)
(format_date_parser.hpp:188)
==11026== by 0x8431435:
boost::date_time::date_input_facet<boost::gregorian::date, char,
std::istreambuf_iterator<char, std::char_traits<char> >
>::date_input_facet(std::string const&, unsigned int) (date_facet.hpp:462)
==11026== by 0x84315E0:
boost::date_time::time_input_facet<boost::posix_time::ptime, char,
std::istreambuf_iterator<char, std::char_traits<char> >
>::time_input_facet(std::string const&, unsigned int) (time_facet.hpp:696)
}}}
The actual problem is in GNU libc6, ''strftime_l.c:574'', which computes a
12 hour clock in `__strftime_internal` regardless of the format string:
{{{
if (hour12 > 12)
hour12 -= 12;
else
if (hour12 == 0)
hour12 = 12;
}}}
The attached patch works around the warning by using an initialised struct
tm in two places:
{{{
tm tm_value = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
}}}
We'd very much appreciate if the attached patch was accepted, even if it
is only cosmetic.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4798> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC