www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22016] New: [REG2.067] Wrong code with enum comparison in

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

          Issue ID: 22016
           Summary: [REG2.067] Wrong code with enum comparison in void
                    ternary with side effects
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

/////////////// test.d //////////////
enum E { one = 1 }
int i;
void gun(int n)
{
    return n == E.one ? ++i : (){}();
}

void main()
{
    gun(1);
    assert(i == 1);
}
/////////////////////////////////////

Introduced in https://github.com/dlang/dmd/pull/3979

--
Jun 11