
including boost/date_time/posix_time/posix_time.hpp or boost/date_time/gregorian/gregorian.hpp gives lots of warning for the following line(s): (boost/date_time/gregorian/conversion.hpp; posix_time, tooo) line 44 std::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone I admit I don't understand the comment. Is it possible to fix that (correctly) such that including the header does not produce like 20 warnings in each .cpp file including the header? (I am using linux running gcc 4.1.2) Best regards Christoph

Christoph wrote:
including boost/date_time/posix_time/posix_time.hpp or boost/date_time/gregorian/gregorian.hpp
gives lots of warning for the following line(s): (boost/date_time/gregorian/conversion.hpp; posix_time, tooo) line 44 std::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone
What warnings?
I admit I don't understand the comment.
std::tm has nonstandard members on some platforms, some of them are pointers. If these members are not zero initialized functions like strftime simply crash.
Is it possible to fix that (correctly) such that including the header does not produce like 20 warnings in each .cpp file including the header? (I am using linux running gcc 4.1.2)
I don't see what's inappropriate in these lines, hence I don't see what to fix.

Andrey Semashev wrote: Thank you for looking into this.
Christoph wrote:
including boost/date_time/posix_time/posix_time.hpp or boost/date_time/gregorian/gregorian.hpp
gives lots of warning for the following line(s): (boost/date_time/gregorian/conversion.hpp; posix_time, tooo) line 44 std::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone
What warnings? These:
boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_sec' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_min' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_hour' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mon' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_year' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_wday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_yday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_isdst' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_gmtoff' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_zone'
I don't see what's inappropriate in these lines, hence I don't see what to fix. Nothing inappropriate, just that g++ is not happy (ok, maybe it is a good idea to compile with -Wno-missing-field-initializers).
Best regards

Christoph Duelli wrote:
Andrey Semashev wrote:
What warnings? These:
boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_sec' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_min' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_hour' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mon' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_year' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_wday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_yday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_isdst' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_gmtoff' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_zone'
Looks like GCC is overreacting. Omitting initializers is fine since these members should be initialized to zero.
I don't see what's inappropriate in these lines, hence I don't see what to fix. Nothing inappropriate, just that g++ is not happy (ok, maybe it is a good idea to compile with -Wno-missing-field-initializers).
[nod]

Andrey Semashev wrote:
Christoph Duelli wrote:
Andrey Semashev wrote:
What warnings? These:
boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_sec' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_min' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_hour' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_mon' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_year' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_wday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_yday' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_isdst' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_gmtoff' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_zone'
Looks like GCC is overreacting. Omitting initializers is fine since these members should be initialized to zero.
Would not {0}, as opposed to {}, be enough to remove the warning? Just guessing ;-) - Volodya

Vladimir Prus wrote:
Andrey Semashev wrote:
Christoph Duelli wrote:
Andrey Semashev wrote:
What warnings? These:
boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_sec' boost_1_40_0/include/boost/date_time/gregorian/conversion.hpp:44: warning: missing initializer for member 'tm::tm_min'
Looks like GCC is overreacting. Omitting initializers is fine since these members should be initialized to zero.
Would not {0}, as opposed to {}, be enough to remove the warning? Just guessing ;-) No. That makes g++ happy about the first member (tm::tm_sec) and leaves it complaining about the rest. If you want the code to compile for different tm struct definitions (more members...) you either have to leave the code as it is (and maybe tell the compiler to shut up), or replace it by a memset (little performance penalty compared to ={}, I guess.)
participants (4)
-
Andrey Semashev
-
Christoph
-
Christoph Duelli
-
Vladimir Prus