Bug 2064 – Segfault with mixin(for/foreach) with empty loop body

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-05-02T13:39:00Z
Last change time
2015-06-09T01:21:36Z
Keywords
ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
bartosz

Comments

Comment #0 by bartosz — 2008-05-02T13:39:50Z
This (incorrect) program causes the compiler to fault. import std.stdio; import std.string; void main () { string s = "abc"; mixin ("foreach (c; s)"); { writeln (c); } }
Comment #1 by clugdbug — 2008-06-23T08:07:04Z
Reduced test case, shows that the problem is a for/foreach with empty body. I've changed the bug title accordingly. Also happens on dmd 1.031. ---- void main () { mixin (`for(;;)`); } --- bug.d(3): found 'EOF' instead of statement then segfaults.
Comment #2 by clugdbug — 2009-04-03T06:30:57Z
statement.c, in Statement *ForStatement::semantic(Scope *sc) around line 1129. body = body->semantic(sc); but body is null in this case. Trivial fix: if (body) body = body->semantic(sc);
Comment #3 by clugdbug — 2009-04-18T01:03:48Z
Fixed DMD2.028