Re: [Boost-bugs] [Boost C++ Libraries] #3563: Warnings using g++ 4.4.0 on date_time/posix_time/conversion.hpp

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3563: Warnings using g++ 4.4.0 on date_time/posix_time/conversion.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-06 20:41:22


#3563: Warnings using g++ 4.4.0 on date_time/posix_time/conversion.hpp
--------------------------+-------------------------------------------------
 Reporter: anonymous | Owner: az_sw_dude
     Type: Patches | Status: new
Milestone: Boost 1.42.0 | Component: date_time
  Version: Boost 1.42.0 | Severity: Cosmetic
 Keywords: |
--------------------------+-------------------------------------------------

Comment(by Justin Randall <logicle@…>):

 Explicit initialization isn't really a portable option, since some
 platforms don't define tm::tm_gmtoff or tm::tm_zone. std::memset from
 cstring would do the trick, and it's something used elsewhere in the boost
 libraries.

 I have a local change from boost-trunk that fixes g++ warnings. This might
 not be the best fix, but it has me up and running locally without
 suppressing g++ warnings for my own code.


 {{{
 Index: posix_time/conversion.hpp
 ===================================================================
 --- posix_time/conversion.hpp (revision 59528)
 +++ posix_time/conversion.hpp (working copy)
 @@ -8,7 +8,7 @@
   * Author: Jeff Garland, Bart Garst
   * $Date$
   */
 -
 +#include <cstring>
  #include <boost/date_time/posix_time/ptime.hpp>
  #include <boost/date_time/posix_time/posix_time_duration.hpp>
  #include <boost/date_time/filetime_functions.hpp>
 @@ -43,7 +43,8 @@
    //! Convert a time_duration to a tm structure truncating any fractional
 seconds and zeroing fields for date components
    inline
    std::tm to_tm(const boost::posix_time::time_duration& td) {
 - std::tm timetm = {};
 + std::tm timetm;
 + std::memset(&timetm, 0, sizeof(timetm));
      timetm.tm_hour = date_time::absolute_value(td.hours());
      timetm.tm_min = date_time::absolute_value(td.minutes());
      timetm.tm_sec = date_time::absolute_value(td.seconds());
 Index: gregorian/conversion.hpp
 ===================================================================
 --- gregorian/conversion.hpp (revision 59528)
 +++ gregorian/conversion.hpp (working copy)
 @@ -9,6 +9,7 @@
   * $Date$
   */

 +#include <cstring>
  #include <string>
  #include <stdexcept>
  #include <boost/throw_exception.hpp>
 @@ -41,7 +42,8 @@
          boost::throw_exception(std::out_of_range(s));
      }

 - std::tm datetm = {}; // zero initialization is needed for extension
 members, like tm_zone
 + std::tm datetm;
 + std::memset(&datetm, 0, sizeof(datetm));
      boost::gregorian::date::ymd_type ymd = d.year_month_day();
      datetm.tm_year = ymd.year - 1900;
      datetm.tm_mon = ymd.month - 1;
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3563#comment:2>
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:02 UTC