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: | 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)
Change History (7)
by , 9 years ago
Attachment: | boost-posix-date-time-overflow.cpp added |
---|
comment:1 by , 9 years ago
I hit this issue as well.
The documentation says duration::total_seconds() returns long, whereas it currently incorrectly returns int.
by , 9 years ago
Attachment: | date_time_ticket_9489.patch added |
---|
A patch, as proposed by the ticket author.
comment:2 by , 9 years ago
Cc: | added |
---|
comment:3 by , 5 years ago
Milestone: | To Be Determined → Boost 1.67.0 |
---|
This was resolved as part of github issue 56:
https://github.com/boostorg/date_time/commit/de171954fe45e4d1338a641ebe70a84a181bd258
The type has been changed to int64_t.
Additional y2038 issues were also found in #11142:
comment:4 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix merged to master; resolved.
Test program to reproduce the error