[Boost-bugs] [Boost C++ Libraries] #6898: Compiler warning when using boost::posix_time::from_ftime.

Subject: [Boost-bugs] [Boost C++ Libraries] #6898: Compiler warning when using boost::posix_time::from_ftime.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-14 11:53:38


#6898: Compiler warning when using boost::posix_time::from_ftime.
--------------------------------------------+-------------------------------
 Reporter: oscar.lara@… | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.42.0 | Severity: Cosmetic
 Keywords: |
--------------------------------------------+-------------------------------
 VC2005 compiler reports a compilation warning when using from_time
 function.

 1>c:\workspace\boost\boost\date_time\filetime_functions.hpp(146) : warning
 C4244: 'initializing' : conversion from 'boost::uint64_t' to
 'boost::uint32_t', possible loss of data
 1> c:\workspace\boost\boost\date_time\posix_time\conversion.hpp(81)
 : see reference to function template instantiation 'TimeT
 boost::date_time::time_from_ftime<TimeT,FileTimeT>(const FileTimeT &)'
 being compiled
 1> with
 1> [
 1> TimeT=boost::posix_time::ptime,
 1> FileTimeT=FILETIME
 1> ]
 1> c:\workspace\blah\rainbowkeyimpl.cpp(126) : see reference to
 function template instantiation 'TimeT
 boost::posix_time::from_ftime<boost::posix_time::ptime,FILETIME>(const
 FileTimeT &)' being compiled
 1> with
 1> [
 1> TimeT=boost::posix_time::ptime,
 1> FileTimeT=FILETIME
 1> ]

 Looking the code in the latest Boost version the line that the warning is
 pointing hasn't changed.

 uint32_t sub_sec = (caster.as_integer % 10000000UL)
 #if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
         / 10; // microseconds since the last second
 #else
         * 100; // nanoseconds since the last second
 #endif

 A quick way to resolve it would be to static_cast<uint32_t> the results.
 The cast shouldn't cause any data loss as the mod is and the
 multiplication are keeping the maximum value within the uint32_t range.

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