Opened 11 years ago
Closed 9 years ago
#5550 closed Bugs (fixed)
Missing initializer warning in date_time/date_facet.hpp
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | To Be Determined | Component: | date_time |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: | manish.mulimani@…, derek@… |
Description
include/boost/date_time/date_facet.hpp is causing a compiler warning
Compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Compiler Options: g++4 -shared -fpic -g -Wall -Woverloaded-virtual -Werror -Wl,--warn-shared-textrel -Wl,--fatal-warnings
cc1plus: warnings being treated as errors boost_1_46_1/include/boost/date_time/date_facet.hpp: In member function ‘OutItrT boost::date_time::date_facet<date_type, CharT, OutItrT>::put(OutItrT, std::ios_base&, CharT, const typename date_type::month_type&) const [with date_type = boost::gregorian::date, CharT = char, OutItrT = std::ostreambuf_iterator<char, std::char_traits<char> >]’: boost_1_46_1/include/boost/date_time/gregorian/gregorian_io.hpp:243: instantiated from ‘std::basic_ostream<_CharT, _Traits>& boost::gregorian::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::gregorian::greg_month&) [with CharT = char, TraitsT = std::char_traits<char>]’ <source>.cpp:##: instantiated from here boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_sec’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_min’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_hour’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_mday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_mon’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_year’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_wday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_yday’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_isdst’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_gmtoff’ boost_1_46_1/include/boost/date_time/date_facet.hpp:211: warning: missing initializer for member ‘tm::tm_zone’
std::tm dtm = {}; should be changed to something like std::tm dtm = std::tm();
This same issue was addressed and fixed in #3563
Attachments (1)
Change History (10)
comment:1 by , 11 years ago
Component: | None → date_time |
---|---|
Owner: | set to |
comment:3 by , 11 years ago
Cc: | added |
---|
comment:4 by , 11 years ago
Cc: | added |
---|---|
Severity: | Cosmetic → Problem |
This is breaking our compilation, so I am upgrading it from cosmetic to a problem. Please submit patch.
comment:5 by , 10 years ago
comment:6 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:7 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | Boost 1.46.1 → Boost 1.54.0 |
This problem is there at two more places in another file (boost 1.54 beta1), giving the same errors/warnings as above.
/date_time/strings_from_facet.hpp:53:20: warning: missing initializer for member ‘tm::tm_gmtoff’ [-Wmissing-field-initializers] (and ten more like it)
/date_time/strings_from_facet.hpp:106:20: warning: missing initializer for member ‘tm::tm_zone’ [-Wmissing-field-initializers] (and ten more like it)
Now, changeset https://svn.boost.org/trac/boost/changeset/80797 suggest the change from
tm tm_value = {};
to
std::tm dtm; std::memset(&dtm, 0, sizeof(dtm));
I've made this change (at two places) and that silences all related warnings. Using the more obvious tm_value = {0,0,0,0,0,0,0,0,0} is not a good idea since some implementations add their own values at the end of the struct.
How to reproduce:
#include "date_time/posix_time/posix_time.hpp" int main(){}
compile with gcc4.7.2, default options.
comment:9 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Setting component to date_time