Bug 17437 – Incorrect range check when implicitly converting integer literals to float/double
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-05-25T23:35:06Z
Last change time
2018-01-25T18:21:44Z
Assigned to
No Owner
Creator
kinke
Comments
Comment #0 by kinke — 2017-05-25T23:35:06Z
The integer value is cast to float/double, and that value is then compared for equality against the original integer value. The comparison is thus performed incorrectly as floating-point type with a potentially smaller integer range. `long.max` (2^63-1) cannot be represented as double, it's rounded up to 2^63, but a `double f = 0x1.0p+63` equals a `long i = long.max` as the comparison is performed as double (and thus `i` rounded up too).
See https://github.com/dlang/dmd/pull/6831.
Comment #1 by github-bugzilla — 2018-01-25T18:21:42Z