|
Boost : |
From: Clark Sims (clark_sims_boost_at_[hidden])
Date: 2007-01-21 20:43:07
Valgrind complains
==6809== Conditional jump or move depends on uninitialised value(s)
==6809== at 0x1BAB1CF8: strftime_l (in /lib/libc-2.3.5.so)
==6809== by 0x1B9D83BD: std::__timepunct<char>::_M_put(char*, unsigned, char const*, tm const*) const (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.so.5.0.7)
==6809== by 0x1B9AF8FC: 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/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.so.5.0.7)
==6809== by 0x1B9AF6AB: _ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPK2tmPKcSB_ (in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.so.5.0.7)
==6809== by 0x806779C: 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:57)
==6809== by 0x8058D68: boost::date_time::format_date_parser<boost::gregorian::date, char>::format_date_parser(std::string const&, std::locale const&) (format_date_parser.hpp:152)
==6809== by 0x8057D0E: 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) (date_facet.hpp:476)
==6809== by 0x80553D8: boost::date_time::time_input_facet<boost::posix_time::ptime, char, std::istreambuf_iterator<char, std::char_traits<char> > >::time_input_facet(unsigned) (time_facet.hpp:660)
==6809== by 0x80532EB: _ZN5boost10local_timersIcSt11char_traitsIcEEERSt13basic_istreamIT_T0_ES8_RNS0_20local_date_time_baseINS_10posix_time5ptimeENS_9date_time14time_zone_baseISB_cEEEE (
You can get this error by compiling the program io_tutorial.cpp and running it under valgrind.
I fixed the problem by calling memset, to initialize the variable tm_value to 0. I put this at lines 54 and 107 of the header file.
diff produces this output:
54d53
< memset( &tm_value, 0, sizeof(tm_value));
107d105
< memset( &tm_value, 0, sizeof(tm_value));
Now Valgrind is happy
---------------------------------
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk