August 07, 2019 [Issue 20114] New: -checkaction=context evaluates operand second time on assertion failure | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: dkorpel@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. -- |
Copyright © 1999-2021 by the D Language Foundation