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:3 by anonymous, 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 James E. King, III, 5 years ago

Owner: changed from az_sw_dude to James E. King, III
Status: newassigned

comment:5 by James E. King, III, 5 years ago

Milestone: To Be DeterminedBoost 1.66.0
Resolution: duplicate
Status: assignedclosed
Note: See TracTickets for help on using tickets.