[Issue 4371] segfault(template.c) template tuple [misuse?]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 26 00:45:50 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4371


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

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


--- Comment #1 from Don <clugdbug at yahoo.com.au> 2010-11-26 00:44:26 PST ---
There are two issues:
(1) deduceType() can return a tuple. This causes the segfault, because it isn't
a type.
Fixing that stops the crash, but the code still doesn't work, because...
(2) Same as bug 5164: it shouldn't try to add the symbol twice. Exactly the
same fix works here.

PATCH: expression.c, line 5185, IsExp::semantic().
----------
Lyes:
    if (id)
    {
-        Dsymbol *s = new AliasDeclaration(loc, id, tded);
+        Dsymbol *s;
+        if (isTuple(tded))
+            s = new TupleDeclaration(loc, id, &(isTuple(tded)->objects));
+        else 
+            s = new AliasDeclaration(loc, id, tded);
        s->semantic(sc);
-        if (!sc->insert(s))
-            error("declaration %s is already defined", s->toChars());
        if (sc->sd)
            s->addMember(sc, sc->sd, 1);
+        else if (!sc->insert(s))
+            error("declaration %s is already defined", s->toChars());
    }
    //printf("Lyes\n");
    return new IntegerExp(loc, 1, Type::tbool);

Lno:
    //printf("Lno\n");
    return new IntegerExp(loc, 0, Type::tbool);

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


More information about the Digitalmars-d-bugs mailing list