Bug 9113 – ICE(interpret.c): CTFE assignment to member of struct in union

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-05T00:22:00Z
Last change time
2015-06-09T05:11:56Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2012-12-05T00:22:34Z
union U9113 { struct M { int y; } int xx; } int bug9113() { U9113 x; x.M.y = 10; return 1; } static assert( bug9113() ); --- dmd: interpret.c:158: void CtfeStack::setValue(VarDeclaration*, Expression*): Assertion `v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()' failed. Aborted
Comment #1 by clugdbug — 2012-12-05T02:14:37Z
This is quite amazing, the semantic pass turns the function body into: { U9113 x = 0; y = 10; return 1; } CTFE is complaining (correctly) that y was not declared. I'm not sure how this gets past code generation.
Comment #2 by clugdbug — 2012-12-05T06:27:52Z
Comment #3 by github-bugzilla — 2012-12-06T08:07:43Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/058a16cdbbe9c32cd75b2a1ea2dbfb8a0bcc45d3 Fix issue 9113 ICE(interpret.c): CTFE assignment to member of struct in union The ICE was caused by the error being detected too late. Move the "needs 'this' pointer" error message from e2ir.c into semantic, instead of creating an invalid expression.
Comment #4 by github-bugzilla — 2012-12-15T11:49:41Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4d4be85d488aaf2171a85de072370309483fdbb5 Fix issue 9113 ICE(interpret.c): CTFE assignment to member of struct in union The ICE was caused by the error being detected too late. Move the "needs 'this' pointer" error message from e2ir.c into semantic, instead of creating an invalid expression.