July 24, 2016
https://issues.dlang.org/show_bug.cgi?id=16317

          Issue ID: 16317
           Summary: Wrong binop evaluation/load order when optimizing
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: kinke@gmx.net

The runtime assertion fails when specifying `-O`:

-----
int add8ret3(ref int s)
{
    s += 8;
    return 3;
}

int binAdd(int val)
{
    val = val + add8ret3(val);
    return val;
}

void main()
{
    assert(binAdd(1) == (1 + 3));
    static assert(binAdd(1) == (1 + 3));
}
-----

So the left hand side lvalue seems to be loaded after evaluating the right hand side. This can be caused by optimizing `val = val <op> ...` to `val <op>= ...`, which isn't valid for the current evaluation/load order rules.

This came up when fixing a related CTFE issue in https://github.com/dlang/dmd/pull/5966, where I disabled the corresponding tests for now.

--