Bug 22016 – [REG2.067] Wrong code with enum comparison in void ternary with side effects
Status
RESOLVED
Resolution
WORKSFORME
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-06-11T07:09:25Z
Last change time
2022-12-23T08:21:39Z
Keywords
backend, pull, wrong-code
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2021-06-11T07:09:25Z
/////////////// 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
Comment #1 by dlang-bot — 2021-06-18T10:46:03Z
@RazvanN7 created dlang/dmd pull request #12705 "Fix Issue 22016 - [REG2.067] Wrong code with enum comparison in void ternary with side effects" fixing this issue:
- Fix Issue 22016 - [REG2.067] Wrong code with enum comparison in void ternary with side effects
https://github.com/dlang/dmd/pull/12705
Comment #2 by bugzilla — 2022-12-23T08:21:39Z
This compiles and runs without error on master, with and without -O.