[Issue 20114] New: -checkaction=context evaluates operand second time on assertion failure
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 7 20:41:56 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20114
Issue ID: 20114
Summary: -checkaction=context evaluates operand second time on
assertion failure
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
```
int fun() {
static int i = 100;
assert(i++ == 100);
return 3;
}
void main() {
assert(fun() == 4);
}
```
Expectation: an assertion failure 3 != 4
Actual output: assertion failure 102 != 100 on line 3
The reason is that fun() is called a second time.
Then it finds 101 != 100 so another assertion failure happens before 3 != 4 can
be printed. There, again, i++ is evaluated a second time so it says 102 != 100
instead of 101 != 100.
--
More information about the Digitalmars-d-bugs
mailing list