[Boost-bugs] [Boost C++ Libraries] #2818: boost::posix_time::from_time_t() assumes boost::int32_t == long

Subject: [Boost-bugs] [Boost C++ Libraries] #2818: boost::posix_time::from_time_t() assumes boost::int32_t == long
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-03-02 22:33:42


#2818: boost::posix_time::from_time_t() assumes boost::int32_t == long
----------------------------------+-----------------------------------------
 Reporter: pelee_at_[hidden] | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: date_time
  Version: Boost Release Branch | Severity: Problem
 Keywords: |
----------------------------------+-----------------------------------------
 boost::posix_time::from_time_t() uses a static_cast<long> to coerce the
 argument t to the appropriate type for the function seconds(), which
 expects a boost::int32_t. On an LP64 platform like MacOS 10.5, long is 64
 bits, so this is incorrect and generates a warning about possible
 truncation. The corrected function should be:


 {{{
   //! Function that converts a time_t into a ptime.
   inline
   ptime from_time_t(std::time_t t)
   {
     ptime start(gregorian::date(1970,1,1));
         return start + seconds(static_cast<boost::int32_t>(t));
   }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2818>
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:49:59 UTC