Bug 3344 – ICE(e2ir.c) returning an invalid function from main()

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2009-09-25T05:31:00Z
Last change time
2014-02-15T13:13:08Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
rayerd.wiz

Comments

Comment #0 by rayerd.wiz — 2009-09-25T05:31:50Z
>type main.d void f(T)(){} void main() { return f; } >dmd main f(T) Internal error: e2ir.c 644
Comment #1 by clugdbug — 2009-09-25T05:38:45Z
Not a D2 bug. Fails even in DMD 0.165.
Comment #2 by clugdbug — 2009-09-29T01:24:49Z
This is clearly invalid code.
Comment #3 by clugdbug — 2009-09-29T01:24:55Z
This is happening because when return exp; is changed into exp; return;, the semantic pass never gets run on the expression. ------- PATCH: iin statement.c, around line 3464, in Statement *ReturnStatement::semantic(Scope *sc) ===== /* Replace: * return exp; * with: * exp; return; */ Statement *s = new ExpStatement(loc, exp); + s->semantic(sc); ========== CAUTION: This patch also disallows code like " void foo() { return 7; }" This shows up several bugs in Phobos and in the DMD test suite. If there's a reason why such bug-prone code should continue to be accepted, a more complicated patch will be required.
Comment #4 by bugzilla — 2009-10-13T13:48:24Z
Fixed dmd 1.049 and 2.034