Bug 16579 – ReturnStatement[CallExp(DotVarExp)]: Corrupted runtime on missed manifest constant propagation

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-03T08:48:54Z
Last change time
2021-12-14T10:34:09Z
Keywords
pull
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2016-10-03T08:48:54Z
Probably related to issue 16576, if not identical (just another angle of the same issue). Working example: --- struct Thing { enum Instance = Thing(); int a = 42; void iter() { import std.stdio; writeln(this.a); // Prints "42" } } void main() { Thing.Instance.iter; } --- Broken example: --- struct Thing { enum Instance = Thing(); int a = 42; void iter() { import std.stdio; writeln(this.a); // Prints "0" } } void main() { return Thing.Instance.iter; // Added 'return' } --- In the bad code, the frontend gives us a CallExp for: Instance.iter() In the good code, the frontend gives us a CallExp for: Thing().iter() So it looks on the surface that constfold has missed a case where it should have propagated the manifest 'Instance' into a literal 'Thing()'.
Comment #1 by ibuclaw — 2016-10-03T08:51:17Z
Extracted from GDC bug report, a fix for the backend to handle the "bad" frontend AST is about to be pushed in. https://bugzilla.gdcproject.org/show_bug.cgi?id=242
Comment #2 by boris2.9 — 2021-11-12T03:20:42Z
*** Issue 16576 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2021-11-12T03:24:57Z
@BorisCarvajal created dlang/dmd pull request #13290 "Fix Issue 16579 - Corrupted runtime on missed manifest constant propagation" fixing this issue: - Fix Issue 16579 - ReturnStatement[CallExp(DotVarExp)]: Corrupted runtime on missed manifest constant propagation A void returning statement 'return exp;' is rewritten to 'exp; return;' but in that case an optimize() call was missing, which was just a little above. https://github.com/dlang/dmd/pull/13290
Comment #4 by dlang-bot — 2021-11-13T03:36:46Z
dlang/dmd pull request #13290 "Fix Issue 16579 - Corrupted runtime on missed manifest constant propagation" was merged into stable: - 07fac3df19f026a7d04c59177287e6434981bfb0 by Boris Carvajal: Fix Issue 16579 - ReturnStatement[CallExp(DotVarExp)]: Corrupted runtime on missed manifest constant propagation A void returning statement 'return exp;' is rewritten to 'exp; return;' but in that case an optimize() call was missing, which was just a little above. https://github.com/dlang/dmd/pull/13290
Comment #5 by dlang-bot — 2021-12-14T10:34:09Z
dlang/dmd pull request #13421 "merge stable" was merged into master: - 5963faf30fadd73f3ad56b5655a083962e85a80d by Boris Carvajal: Fix Issue 16579 - ReturnStatement[CallExp(DotVarExp)]: Corrupted runtime on missed manifest constant propagation A void returning statement 'return exp;' is rewritten to 'exp; return;' but in that case an optimize() call was missing, which was just a little above. https://github.com/dlang/dmd/pull/13421