Opened 8 years ago
Closed 8 years ago
#10995 closed Bugs (fixed)
duration_put::put_value truncates fractional part
Reported by: | rkawulak | Owned by: | viboes |
---|---|---|---|
Milestone: | Boost 1.58.0 | Component: | chrono |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
For durations with a floating-point Rep type, duration_put::put_value truncates fractional part because it makes static_cast<long int>(d.count()). I guess this code will also be broken if Rep is unsigned long or larger integral type, causing an overflow.
Change History (5)
comment:1 by , 8 years ago
Milestone: | To Be Determined → Boost 1.58.0 |
---|
comment:2 by , 8 years ago
Status: | new → assigned |
---|
comment:3 by , 8 years ago
Seems this won't work for types narrower than int_least32_t. (And why int_least32_t in particular and not int?) I guess it would be more correct to have three SFINAE-enabled trait specialisations for all signed integral, all unsigned integral and all floating-point types, promoting them to the largest corresponding type.
comment:4 by , 8 years ago
Right, the issue I found is with int.
I don't remember if there is a constraint on the representation, but IMO, it is weird to use unsigned for duration.
comment:5 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
While analyzing #11012 I found a solution https://github.com/boostorg/chrono/commit/300c0c69631de7dcc9e555bdc8ff217d9a25bb88.
Let me know if this works for you.