Opened 6 years ago
Closed 5 years ago
#12214 closed Bugs (duplicate)
boost::posix_time::time_duration::sec_type is too small!
Reported by: | anonymous | Owned by: | James E. King, III |
---|---|---|---|
Milestone: | Boost 1.66.0 | Component: | date_time |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | Cc: |
Description
This code:
sec_type total_seconds() const {
return static_cast<sec_type>(ticks() / ticks_per_second());
}
is unsafe as sec_type is int32_t while ticks() is int64_t.
See this post for an easy way to have inconsistent result when using boost::posix_time::time_duration::total_seconds().
sec_type should be enlarged to int64_t
Change History (5)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
comment:3 by , 6 years ago
It looks like time_resolution_traits::v_type (boost/date_time/time_resolution_traits.hpp) should be changed to
typename v_type = boost::int64_t
for all the typedefs: day_type, hour_type, min_type, sec_type.
At the moment it uses int32_t.
comment:4 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 5 years ago
Milestone: | To Be Determined → Boost 1.66.0 |
---|---|
Resolution: | → duplicate |
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Forgot the link to "this post": http://stackoverflow.com/questions/37299652/whats-wrong-with-boostposix-timetime-durationtotal-seconds