Issue 3996 - Regression(2.041) ICE(glue.c) Passing struct as AA template parameter (Algebraic with struct)
Summary: Regression(2.041) ICE(glue.c) Passing struct as AA template parameter (Algebr...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
: 4449 (view as issue list)
Depends on:
Blocks:
 
Reported: 2010-03-21 06:51 UTC by Michel Fortin
Modified: 2014-02-15 02:42 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michel Fortin 2010-03-21 06:51:37 UTC
DMD 2.041 and 2.042 on Mac OS X crash with this input. It was working a few versions before, but I don't know exactly at which point it broke.

import std.variant;
struct A {}
alias Algebraic!(A) sts;
Comment 1 Don 2010-06-09 11:57:21 UTC
Reduced test case shows it's a regression from AAs becoming a library type.

template ICE3996(T : V[K], K, V) {}

struct Bug3996 {}

static assert(!is( ICE3996!(Bug3996) ));
Comment 2 Don 2010-06-15 07:21:22 UTC
I think the root cause of this is bug 4269.
Comment 3 Don 2010-07-13 08:14:34 UTC
*** Issue 4449 has been marked as a duplicate of this issue. ***
Comment 4 Don 2010-09-06 14:01:17 UTC
This turns out to be simple. When there's an error in the AA parameters, it should not continue to instantiate the template.
There's no "error declaration", so return a struct of type TError. Not sure if it's OK to give it no name.
(Would also be possible to return NULL in this case, but then everything that calls it would need to be changed, to prevent segfaults).

PATCH(mtype.c): Line 3966

StructDeclaration *TypeAArray::getImpl()
{
    // Do it lazily
    if (!impl)
    {
        Type *index = this->index;
        Type *next = this->next;
        if (index->reliesOnTident() || next->reliesOnTident())
        {
            error(loc, "cannot create associative array %s", toChars());
            index = terror;
            next = terror;
+            StructDeclaration *s = new StructDeclaration(0, NULL);
+            s->type = terror;
+            return s;
        }
Comment 5 Walter Bright 2010-09-11 14:17:47 UTC
http://www.dsource.org/projects/dmd/changeset/672