Permalink
Browse files

fix Issue 9278 - ICE todt.c:692 when float containing struct is defin…

…ed after use
  • Loading branch information...
1 parent 5f5ec27 commit 7ca2ea99e56aa59b604dbd68555e2d967beb18c0 @9rnsr 9rnsr committed Jan 9, 2013
Showing with 37 additions and 1 deletion.
  1. +5 −1 src/mtype.c
  2. +16 −0 test/compilable/test9278a.d
  3. +16 −0 test/compilable/test9278b.d
View
@@ -8154,6 +8154,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
for (size_t j = 0; j < structelems->dim; j++)
{
VarDeclaration *vd = sym->fields[j];
+ Type *telem = vd->type->addMod(this->mod);
Expression *e;
if (vd->init)
{ if (vd->init->isVoidInitializer())
@@ -8164,7 +8165,10 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
else
e = vd->type->defaultInitLiteral(loc);
if (e && vd->scope)
- e = e->semantic(vd->scope);
+ {
+ e = e->semantic(vd->scope);
+ e = e->implicitCastTo(vd->scope, telem);
+ }
(*structelems)[j] = e;
}
StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems);
@@ -0,0 +1,16 @@
+// PREMUTE_ARGS:
+
+// Works fine here
+struct datum { float num = 0.0; }
+
+datum emitOne()
+{
+ datum t;
+ return t;
+}
+const dataArr = [emitOne()];
+
+// A very bad day
+//struct datum { float num = 0.0; }
+
+void main(){}
@@ -0,0 +1,16 @@
+// PREMUTE_ARGS:
+
+// Works fine here
+//struct datum { float num = 0.0; }
+
+datum emitOne()
+{
+ datum t;
+ return t;
+}
+const dataArr = [emitOne()];
+
+// A very bad day
+struct datum { float num = 0.0; }
+
+void main(){}

0 comments on commit 7ca2ea9

Please sign in to comment.