Bug 20114 – -checkaction=context evaluates operand second time on assertion failure
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-08-07T20:41:56Z
Last change time
2019-11-06T20:53:35Z
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2019-08-07T20:41:56Z
```
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.
Comment #1 by dlang-bot — 2019-10-27T17:59:51Z
@MoonlightSentinel created dlang/dmd pull request #10512 "Issue 20114 - -checkaction=context evaluates operand second time on a…" mentioning this issue:
- Issue 20114 - -checkaction=context evaluates operand second time on assertion failure
https://github.com/dlang/dmd/pull/10512
Comment #2 by dlang-bot — 2019-11-06T20:53:07Z
dlang/dmd pull request #10512 "Issue 20114 - -checkaction=context evaluates operand second time on a…" was merged into master:
- 0ae5f75fce4b8a24341e0b4317f01aedd740aa6e by MoonlightSentinel:
Issue 20114 - -checkaction=context evaluates operand second time on assertion failure
https://github.com/dlang/dmd/pull/10512