www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24185] New: Constant folding differs between Windows and

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

          Issue ID: 24185
           Summary: Constant folding differs between Windows and linux
                    builds
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

DMD 2.105.2:

---
void main(){
    import std.stdio;
    assert(42*6==252);
    assert(cast(int)(4.2*60)==251); // passes on linux, fails on windows
    double x=4.2;
    assert(cast(int)(x*60)==252); // passes on both
}
---

Constant folding/CTFE of floating-point code differs between compile time and
runtime, and it differs even between platforms.

--
Oct 13 2023