[Issue 22016] New: [REG2.067] Wrong code with enum comparison in void ternary with side effects

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 11 07:09:25 UTC 2021


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 at puremagic.com
          Reporter: dlang-bugzilla at 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

--


More information about the Digitalmars-d-bugs mailing list