Bug 3357 – ICE(cod1.c) using 'in' with a static char array as AA key
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-10-01T08:05:00Z
Last change time
2014-04-18T09:12:06Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
fawzi
Comments
Comment #0 by fawzi — 2009-10-01T08:05:44Z
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 by clugdbug — 2009-10-01T08:11:41Z
Is this the same as bug 1934?
Comment #2 by fawzi — 2009-10-01T08:21:28Z
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 by clugdbug — 2009-10-01T08:33:01Z
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 by fawzi — 2009-10-01T08:35:40Z
thanks for catching it...
Comment #5 by clugdbug — 2009-10-06T00:26:37Z
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);