[Issue 5188] alias this and compare expression generates wrong code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 22 03:13:23 PDT 2011


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


kennytm at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |kennytm at gmail.com
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #1 from kennytm at gmail.com 2011-07-22 03:13:19 PDT ---
If we set a break point at FuncDeclaration::toObjFile at glue.c and print
'fbody->toChars()', we'll see that the function


   void main() {
      S s;
      assert(s <= 20);    // fail!?
   }


has been semantic into

   int main() {
      S s = _D1x1S6__initZ;
      assert(cast(int)(s.v <= 20) <= 0);
   //                             ^^
      return 0;
   }

The extra '<= 0' causes the assertion to fail. Apparently DMD thinks there is
an opCmp/opEquals. This also applies for '!=':

      assert(s != 14);

which is semantic into

      assert(!(s.v != 14));

-- 
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