https://issues.dlang.org/show_bug.cgi?id=22527
Issue ID: 22527
Summary: Casting out-of-range floating point value to signed
integer overflows
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
As of DMD 2.098.0, the following program fails to compile:
---
static assert(cast(int) float.max > 0);
---
The error message is:
---
Error: static assert: `-2147483648 > 0` is false
---
According to the language spec:
> Casting a floating point value to an integral type is the equivalent of
> converting to an integer using truncation.
Since float.max is a positive number, truncation of its value should result in
a positive integer, not a negative integer.
--