Thread overview
[Issue 3426] New: ICE(optimize.c): struct literal with cast, as function default parameter.
Oct 20, 2009
Don
Nov 01, 2009
Walter Bright
Nov 01, 2009
Kosmonaut
Nov 06, 2009
Walter Bright
October 20, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3426

           Summary: ICE(optimize.c): struct literal with cast, as function
                    default parameter.
           Product: D
           Version: 1.020
          Platform: All
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code, patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2009-10-20 12:17:43 PDT ---
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);
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 01, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3426


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2009-10-31 18:14:32 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 01, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3426


Kosmonaut <Kosmonaut@tempinbox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Kosmonaut@tempinbox.com


--- Comment #2 from Kosmonaut <Kosmonaut@tempinbox.com> 2009-10-31 21:31:22 PDT ---
Fixed in SVN repository: http://www.dsource.org/projects/dmd/changeset/230

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3426


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2009-11-06 11:31:45 PST ---
Fixed dmd 1.051 and 2.036

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------