[Bug c/29023] New: Incorrect optimization of redundant expressions in || expression

Paul dot F dot Dietz at motorola dot com gcc-bugzilla@gcc.gnu.org
Mon Sep 11 20:06:00 GMT 2006


Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-languages=c,c++,objc
--prefix=/software/linux/gcc/4.0.3
Thread model: posix
gcc version 4.0.3

The bug shows up with options -Os or -Ox (x >= 1).  Here is the source file:

main () { 
   unsigned char t1[1];
   t1[0] = 128;
   if (((unsigned char) (t1 [0] & 128) != 128) ||
       ((unsigned char) (t1 [0] & 128) != 128)
      ) printf ("Not Ok\n");
   else printf ("Ok\n");
}

The bug also occurs in 3.4.6, but does not occur in 3.2.3.  I have not tested
it on a compiler newer than 4.0.3.


-- 
           Summary: Incorrect optimization of redundant expressions in ||
                    expression
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Paul dot F dot Dietz at motorola dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29023



More information about the Gcc-bugs mailing list