diff gen/toir.cpp @ 467:261b05cf4d1c

Fixed problem in AssignExp where the result value might be uninitialized. see mini/assign1.d
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 03 Aug 2008 16:59:28 +0200
parents e381e082d5cb
children 45a67b6f1310
line wrap: on
line diff
--- a/gen/toir.cpp	Sun Aug 03 16:16:16 2008 +0200
+++ b/gen/toir.cpp	Sun Aug 03 16:59:28 2008 +0200
@@ -448,7 +448,7 @@
 
 DValue* AssignExp::toElem(IRState* p)
 {
-    Logger::print("AssignExp::toElem: %s | %s = %s\n", toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0);
+    Logger::print("AssignExp::toElem: %s | (%s)(%s = %s)\n", toChars(), type->toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0);
     LOG_SCOPE;
 
     if (e1->op == TOKarraylength)
@@ -472,13 +472,16 @@
     if (l->isSlice() || l->isComplex())
         return l;
 
-    LLValue* v;
-    if (l->isVar() && l->isVar()->lval)
-        v = l->getLVal();
+    if (type->toBasetype()->ty == Tstruct && e2->type->isintegral())
+    {
+        // handle struct = 0;
+        return l;
+    }
     else
-        v = l->getRVal();
-
-    return new DVarValue(type, v, true);
+    {
+        assert(type->equals(e2->type));
+        return r;
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////