D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3357 - ICE(cod1.c) using 'in' with a static char array as AA key
Summary: ICE(cod1.c) using 'in' with a static char array as AA key
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2009-10-01 08:05 UTC by Fawzi Mohamed
Modified: 2014-04-18 09:12 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Fawzi Mohamed 2009-10-01 08:05:44 UTC
I was trying to reduce an error, namely
  Internal error: e2ir.c 4026
and I generated another one
{{{
struct Particle{
    char[16] name;
}

class ReadSystem{
    size_t[char[16]] pKindsIdx;
    
    void t(Particle p){
        auto idx=p.name in pKindsIdx; // fails (Internal error: ../ztc/cod1.c 2636)
    }
}

void main(){
    char[16] n;
    size_t[char[16]] aa;
    auto r=n in aa; // works
}
}}}
Comment 1 Don 2009-10-01 08:11:41 UTC
Is this the same as bug 1934?
Comment 2 Fawzi Mohamed 2009-10-01 08:21:28 UTC
Yes it looks like it, the line number changed (probably due to changes in the code) and I hadn't found it, but it really looks like the same issue.

*** This issue has been marked as a duplicate of issue 1934 ***
Comment 3 Don 2009-10-01 08:33:01 UTC
This isn't the same as bug 1934, though it is clearly very closely related. My patch for 1934 doesn't fix this.
Comment 4 Fawzi Mohamed 2009-10-01 08:35:40 UTC
thanks for catching it...
Comment 5 Don 2009-10-06 00:26:37 UTC
Same cause as bug 1934. The patch I used for IndexExp::toElem() also needs to 
be applied to InExp::toElem().

Index: e2ir.c
===================================================================
--- e2ir.c	(revision 75)
+++ e2ir.c	(working copy)
@@ -2391,6 +2391,13 @@
 	key->Enumbytes = key->E1->Enumbytes;
 	assert(key->Enumbytes);
     }
+    else if (tybasic(key->Ety) == TYarray && taa->index->ty==Tsarray)
+    {	// e2->elem() turns string literals into a TYarray, so the
+	// length is lost. Restore it.
+	key = el_una(OPstrpar, TYstruct, key);
+	assert(e1->type->size() == taa->index->size());
+	key->Enumbytes = taa->index->size();
+    }
 
     Symbol *s = taa->aaGetSymbol("In", 0);
     keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs);
Comment 6 Walter Bright 2009-10-13 13:48:44 UTC
Fixed dmd 1.049 and 2.034