Opened 11 years ago
Last modified 6 years ago
#6280 new Bugs
numeric_cast throws on exactly representable conversion
Reported by: | Owned by: | Douglas Gregor | |
---|---|---|---|
Milestone: | To Be Determined | Component: | numeric |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: |
Description
If a double or float representing the smallest possible value of int64_t is cast to int64_t using numeric_cast, an exception is thrown saying that a negative overflow has occured.
I would expect the cast to work, since the value is exactly representable in the target type. Since the absolute value is a power of two, there should not be any error in the floating point representation.
This is also reproducable in trunk, according to VeXocide. I found the problem in Boost 1.47.0 on Windows, using MinGW 4.5.2.
Attachments (1)
Change History (2)
by , 11 years ago
comment:1 by , 6 years ago
This works for me with Boost 1.58 on Ubuntu, but ldrexp(1, 63)
doesn't throw. See ticket #12252.
Small test program