Thread overview
[Issue 3292] New: ICE(todt.c) when using a named mixin with an initializer
Sep 03, 2009
2korden@gmail.com
Sep 16, 2009
Don
[Issue 3292] ICE(todt.c) when using a named mixin with an initializer as template alias parameter
Sep 30, 2009
Don
Oct 12, 2009
Don
Nov 01, 2009
Kosmonaut
Nov 06, 2009
Walter Bright
September 03, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3292

           Summary: ICE(todt.c) when using a named mixin with an
                    initializer
           Product: D
           Version: 2.031
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: 2korden@gmail.com


template Magic()
{
    void* magic = null;    // remove = null; and bug disappears
}

struct Item
{
    mixin Magic A;
}

struct Foo(alias S)
{
}

void main()
{
    Foo!(Item.A) bar;
}

Assertion failure: 'type' on line 529 in file 'todt.c'

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Version|2.031                       |1.047


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-09-16 00:33:45 PDT ---
This applies equally to D1.047. It's been present since prehistory (fails
identically on DMD0.175).

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(todt.c) when using a    |ICE(todt.c) when using a
                   |named mixin with an         |named mixin with an
                   |initializer                 |initializer as template
                   |                            |alias parameter


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2009-09-29 23:52:44 PDT ---
Another variation gives an ICE in optimize.c. Replace void *magic = null; with
void* magic = cast(void*)(0);
Again, it's because no 'type' is NULL.

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-10-12 01:55:37 PDT ---
This is happening because in this situation, when TemplateMixin::semantic() is called, semanticRun is already 3.

The members get syntax copied:
    // Copy the syntax trees from the TemplateDeclaration
    members = Dsymbol::arraySyntaxCopy(tempdecl->members);

But this destroys their type info, and then since semanticRun is 3, semantic2 never gets run, hence semantic() never gets called on the members ---> they have no type.

I don't think this mixin should be run at all, if it's already done the semantic3 pass. (Note: I have NOT tested this patch against the DMD test suite).

PATCH:
Line 4457, in template.c, TemplateMixin::semantic(Scope *sc)

    if (!semanticRun)
    semanticRun = 1;
+    if (semanticRun >1) return;

----------------------------
But I'm not sure if this is the correct place to do this check. Should it be being asked to do the semantic at all? It's being called from AliasDeclaration::semantic(), and I'm not sure why:

    if (aliassym)
    {
    if (aliassym->isTemplateInstance()) {
        aliassym->semantic(sc);  // Is this correct??
    }
        return;
    }

-- 
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=3292


Kosmonaut <Kosmonaut@tempinbox.com> changed:

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


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

-- 
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=3292


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2009-11-06 11:30:21 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: -------