[Issue 19599] New: Wrong codegen DMD x86_64 with both -O and -inline + double
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jan 21 01:38:35 UTC 2019
    
    
  
https://issues.dlang.org/show_bug.cgi?id=19599
          Issue ID: 19599
           Summary: Wrong codegen DMD x86_64 with both -O and -inline +
                    double
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: aliloko at gmail.com
DMD v2.081.2 
Build this with:
    dmd repro.d -m64 -inline -O           
--------- repro.d -----------
struct double2
{
    double[2] array;
    this(double[2] v) pure nothrow @safe @nogc
    {
        array[] = v[];
    }
    ref inout(double) opIndex(size_t i) inout pure nothrow @safe @nogc
    {
        return array[i];
    }
}
double2 _mm_sub_sd(double2 a, double2 b) pure @safe
{
    a[0] -= b[0];
    return a;
}
void main()
{
    double2 a = [1.0, -2.0];
    a = _mm_sub_sd(a, a);
    assert(a.array == [0.0, -2.0]);
}
```
The assert doesn't pass. Instead a is equal to [1.0, -2.0].
It should be exactly [0.0, -2.0]
--
    
    
More information about the Digitalmars-d-bugs
mailing list