Bug 21598 – checkaction=context reruns pure functions with debug blocks on failure

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-31T14:57:30Z
Last change time
2021-02-01T03:55:48Z
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2021-01-31T14:57:30Z
=========================================== extern(C) int puts(const scope char*); void main() { assert(foo(1)); } int foo(int i) pure nothrow { debug puts("Hello"); return i - 1; } ============================================ Currently outputs: Hello Hello This is caused by dmd omitting the temporary for pure function calls (op.hasSideEffect == false).
Comment #1 by dlang-bot — 2021-02-01T03:55:48Z
dlang/dmd pull request #12170 "Fix 21471,21598 - Always create a temporary for calls with checkactio…" was merged into master: - a956cc1f12ef4ea1f2294285bfab99734c65e446 by MoonlightSentinel: Fix 21471,21598 - Always create a temporary for calls with checkaction=context Using a temporary for every expression that calls another function avoids problems with the inliner and avoids an unexpected secondary function call for `pure` functions (which might have side effects in `debug` blocks). See [bugzilla](https://issues.dlang.org/show_bug.cgi?id=21471) for a more complete writeup of the inliner issue. https://github.com/dlang/dmd/pull/12170