[LLVMbugs] [Bug 1721] Incorrect evaluation of expression containing bitfield items

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Oct 2 21:12:54 PDT 2007


http://llvm.org/bugs/show_bug.cgi?id=1721


Chris Lattner <sabre at nondot.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Chris Lattner <sabre at nondot.org>  2007-10-02 23:12:51 ---
This is not a bug.  GCC happens to miscompile this code, but LLVM does it
correctly.  Specifically, in this statement:

  if (b.u33 + b.u33 != 0)
    printf ("fail\n");

The two operands to the plus are promoted to their next largest integer size
(int64) before the addition, so the addition is actually produces 1ULL << 33,
and is not subject to truncation.  In other words, the code above is very
different than:

  if (((b.u33 + b.u33) & 0x1FFFFFFFF) != 0)
    printf ("fail\n");


Apple GCC 4.0 appears to get this wrong, but LLVM does compile it correctly.

-Chris


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list