www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13237] New: Wrong code with "-inline -O"

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

          Issue ID: 13237
           Summary: Wrong code with "-inline -O"
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: sinkuu aol.jp

introduced by https://github.com/D-Programming-Language/dmd/pull/3819


size_t getLength(int[] arr) { return arr.length; }

void main()
{
    int[] arr = [0];
    immutable size_t len = getLength(arr);

    arr.length--;

    assert(len == 1); // ok
    if (len) { auto l = len; }
    assert(len == 1); // len cannot be changed, but produces Assertion failure
with "-O -inline"
}

--
Aug 01 2014