We found an inconsistent result when we were testing the options used to build
Linux kernels. See the code below. BTW, I am using r154188.

y...@yang-working:~$ svngcc -O1 -o small_1 small.c
y...@yang-working:~$ ./small_1
g = 2
y...@yang-working:~$ svngcc -Os -fno-delete-null-pointer-checks -o small_s
small.c
y...@yang-working:~$ ./small_s
g = 1
y...@yang-working:~$ cat small.c
#include <stdio.h>

int g = 0;

static int
foo(int ui1, int ui2)
{
 if (ui2 == 0)
   return ui1;
 else
   return ui1 + ui2;
}

void func_2(long long p);
void func_2(long long p)
{
   if ((g > p) == (g <= foo(8, (&g != 0))))
   {
       g = 1;
   }
   else
   {
       g = 2;
   }
}

int main(void)
{
   func_2(1);
   printf("g = %d\n", g);
   return 0;
}
y...@yang-working:~$ svngcc -v
Using built-in specs.
COLLECT_GCC=svngcc
COLLECT_LTO_WRAPPER=/home/yang/compilers/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-lto --prefix=/home/yang/compilers
--program-prefix=svn --enable-languages=c,c++
--with-libelf=/home/yang/compilers : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,lto,c++ --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion
Thread model: posix
gcc version 4.5.0 20091115 (experimental) (GCC)


-- 
           Summary: Wrong result with -Os -fno-delete-null-pointer-checks
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chenyang at cs dot utah dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to