Bug 3426 – ICE(optimize.c): struct literal with cast, as function default parameter.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
Windows
Creation time
2009-10-20T12:17:00Z
Last change time
2014-02-16T15:21:58Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-10-20T12:17:43Z
An ancient bug: same ICE on D1.020 as on D2.036 TEST CASE: struct Ashes { int ashes = cast(int)0; } void funky (Ashes s = Ashes()) {} void funk() { funky(); } PATCH: This patch also fixes the closely related bug 3422. (The semantic is for this bug. The implicit cast is for bug 3422. The assert is just a precaution). expression.c line 3271. { e = v->type->defaultInit(); e->loc = loc; } offset = v->offset + v->type->size(); } + assert(v->type); + e= e->semantic(sc); + if (e->type !=v->type) e = e->implicitCastTo(sc, v->type); elements->push(e); }
Comment #1 by bugzilla — 2009-10-31T18:14:32Z
The fix for this is somewhat more complicated than the patch. The problem is the scope of the field initializer is the scope of where the field appears, not where the field is used. I'll see if I can fix it.
Comment #2 by Kosmonaut — 2009-10-31T21:31:22Z
Comment #3 by bugzilla — 2009-11-06T11:31:45Z
Fixed dmd 1.051 and 2.036