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: [email protected]
          Reporter: [email protected]

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.

--

Reply via email to