Using r153799, the following program gives strange result with -O3.

y...@yang-working:~$ svngcc -O3 -o small small.c
y...@yang-working:~$ ./small 
g_64 = 0
y...@yang-working:~$ cat small.c
#include <stdio.h>

unsigned int g_64 = 1;

int
main (void)
{
  unsigned int *l_65 = &g_64;
  unsigned int x = 0xC7D24B5E;
  unsigned int y = *l_65 | -2;
  unsigned int m = (y == 0) ? x : (x % y);

  if (m != x)
    {
      g_64 = 0;
    }

  printf ("g_64 = %x\n", g_64);
  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
Thread model: posix
gcc version 4.5.0 20091102 (experimental) (GCC)


-- 
           Summary: Strange athrithmetic result with -O3
           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=41917

Reply via email to