Boost logo

Boost :

Subject: [boost] [DateTime] valgrind warns on uninitialized jump
From: Christoph Duelli (duelli_at_[hidden])
Date: 2009-09-17 09:47:16


[from strings_from_facet.hpp, line 52]

for (int m=0; m < 12; m++) {
   tm tm_value;
   tm_value.tm_mon = m;
   stringstream_type ss;
   ostream_iter_type oitr(ss);
   std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
                                                   &tm_value,
                                                   &*outfmt.begin(),
                                       &*outfmt.begin()+outfmt.size());
   months.push_back(ss.str());
}

valgrind (3.5.0, run on Linux, gcc 4.1.2, libstdc++ 6.0.8) reports:
==13166== 1 errors in context 1 of 1:
==13166== Conditional jump or move depends on uninitialised value(s)
==13166== at 0x41D793D: strftime_l (in /lib/libc-2.4.so)
==13166== by 0x40EE600: std::__timepunct<char>::_M_put(char*, unsigned
int, char const*, tm const*) const (in /usr/lib/libstdc++.so.6.0.8)
==13166== by 0x40AC9DA: 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.8)
==13166== by 0x40AAD95: 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.8)

The "error" goes away when tm_value.tm_hour is initialized to 0.
(No idea why. Might be a bug in libstdc++)

Best regards


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk