Opened 10 years ago
Last modified 5 years ago
#6898 closed Bugs
Compiler warning when using boost::posix_time::from_ftime. — at Version 2
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | Boost 1.66.0 | Component: | date_time |
Version: | Boost 1.42.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description (last modified by )
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.
Change History (2)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Description: | modified (diff) |
---|
Sorry my last sentence was meant to say: ...the mod and the multiplication are keeping