[Issue 17437] New: Incorrect range check when implicitly converting integer literals to float/double

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu May 25 16:35:06 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17437

          Issue ID: 17437
           Summary: Incorrect range check when implicitly converting
                    integer literals to float/double
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: kinke at gmx.net

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.

--


More information about the Digitalmars-d-bugs mailing list