www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17943] New: Wrong pointer arithmetic optimization

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

          Issue ID: 17943
           Summary: Wrong pointer arithmetic optimization
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ilyayaroshenko gmail.com

unittest
{
    int[32] data;
    auto p1 = data.ptr + 0;
    auto p2 = data.ptr + 3;
    assert(p2 - p1 == 3);
}

dmd -release -unittest -main -run test.d
pass

dmd -O -release -unittest -main -run test.d
fails

Tested with DMD 2.076 - 2.077, Linux, OSX.

--
Oct 27