Opened 9 years ago

Closed 5 years ago

#9489 closed Bugs (fixed)

boost::date_time::time_resolution_traits uses 32-bit seconds for 64-bit systems

Reported by: mreissne@… Owned by: James E. King, III
Milestone: Boost 1.67.0 Component: date_time
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc: mail@…

Description

boost::date_time::time_resolution_traits defaults to boost::int32_t for its v_type parameter. This means that for 64-bit systems, such as time_resolution_traits_bi64_impl and time_resolution_traits_adapted64_impl, date-times whose seconds count exceed the int32_t limit will overflow, returning a negative value for boost::posix_time::time_duration::total_seconds.

The attached file reproduces the issue. The output on a 64-bit Intel(R) Xeon system running Linux is:

2038-Jan-19 03:14:08 -2147483648

We have found that changing the v_type definition from boost::int32_t to typename frac_sec_type::int_type resolves the issue by associating v_type with its implementation's definition.

Attachments (2)

boost-posix-date-time-overflow.cpp (1.1 KB ) - added by mreissne@… 9 years ago.
Test program to reproduce the error
date_time_ticket_9489.patch (550 bytes ) - added by maxim.yegorushkin@… 9 years ago.
A patch, as proposed by the ticket author.

Download all attachments as: .zip

Change History (7)

by mreissne@…, 9 years ago

Test program to reproduce the error

comment:1 by maxim.yegorushkin@…, 9 years ago

I hit this issue as well.

The documentation says duration::total_seconds() returns long, whereas it currently incorrectly returns int.

by maxim.yegorushkin@…, 9 years ago

Attachment: date_time_ticket_9489.patch added

A patch, as proposed by the ticket author.

comment:2 by Georg Sauthoff <mail@…>, 9 years ago

Cc: mail@… added

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

Milestone: To Be DeterminedBoost 1.67.0

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

Resolution: fixed
Status: assignedclosed

Fix merged to master; resolved.

Note: See TracTickets for help on using tickets.