[Issue 5735] non-scalar types implicitly converted to boolean.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 6 03:26:12 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5735


Iain Buclaw <ibuclaw at ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Iain Buclaw <ibuclaw at ubuntu.com> 2011-04-06 03:22:23 PDT ---
Rough fix for 2.052 - will try out trunk later on today.

Regards

--- dmd.orig/cast.c     2011-02-18 01:15:38.000000000 +0000
+++ dmd/cast.c  2011-04-06 11:13:50.536604547 +0100
@@ -144,6 +144,10 @@
         type = Type::terror;
     }
     Expression *e = optimize(WANTvalue | WANTflags);
+    if (t->ty == Tbool)
+    {   // See if we can really convert the type to boolean.
+        e->checkToBoolean(NULL);
+    }
     if (e->type == t)
         return MATCHexact;
     if (e != this)
--- dmd.orig/optimize.c 2011-02-18 01:15:38.000000000 +0000
+++ dmd/optimize.c      2011-04-06 10:55:18.075088167 +0100
@@ -990,6 +990,8 @@

                 e = new IntegerExp(loc, n1 || n2, type);
             }
+            else if (! e2->type->checkBoolean())
+                ;   // Don't convert e2 to bool if it's type disallows it.
             else if (e1->isBool(FALSE))
                 e = new BoolExp(loc, e2, type);
         }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list