Bug 5453 – ICE(statement.c): invalid switch statement forward referenced by CTFE

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-01-14T00:17:00Z
Last change time
2015-06-09T05:11:41Z
Keywords
ice-on-valid-code
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2011-01-14T00:17:27Z
Reported by %u. ------------ struct S { static int func() { S s; int e; switch( e ) { default: return 0; } } static int[1] ARR = [func() ]; } ---- Assertion failure: '!cases' on line 2741 in file 'statement.c' abnormal program termination It's happening because the CTFE for ARR speculatively runs func(). There's a 'no size yet for forward referenced struct' error because S isn't complete yet. But this happens with errors gagged. The SwitchStatement completes its semantic pass correctly. But, because "S s;" failed, semantic gets run again for func(), without errors gagged this time. SwitchStatement::semantic() detects it's been run twice, and asserts.
Comment #1 by clugdbug — 2011-07-26T21:11:27Z
*** Issue 6326 has been marked as a duplicate of this issue. ***
Comment #2 by bugzilla — 2011-09-14T00:45:54Z
Comment #3 by bugzilla — 2011-09-15T11:23:45Z