[Bug c/35540] New: Segmentation fault with __builtin_parity() and -O1

r dot schuerer at gmx dot at gcc-bugzilla@gcc.gnu.org
Tue Mar 11 15:12:00 GMT 2008


Consider the following C-Program main.c:

/*********************************************/
int f (unsigned* a, int b)
{
   return b ? 1 : __builtin_parity(*a);
}
int main()
{
   unsigned a = 0;
   return f(&a, 0);
}
/*********************************************/

Using GCC 4.3.0:

$ /usr/local/gcc-4.3.0/bin/gcc-4.3.0 -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.0/configure --prefix=/usr/local/gcc-4.3.0
--program-suffix=-4.3.0 --with-mpfr=/usr/local/ --with-tune=pentium4
--with-arch=pentium4 --enable-languages=c,c++,fortran,java,objc
Thread model: posix
gcc version 4.3.0 (GCC)

When compliled with -O0, the program runs successfully:

$ /usr/local/gcc-4.3.0/bin/gcc-4.3.0 -O0 main.c
$ ./a.out

When complied with -O1, the program segfaults.

$ /usr/local/gcc-4.3.0/bin/gcc-4.3.0 -O1 main.c
$ ./a.out
Segmentation fault

The program runs successfully when compiled with -O2 or -O3.
The program runs successfully with GCC 4.2.3 in all optimization levels.


-- 
           Summary: Segmentation fault with __builtin_parity() and -O1
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: r dot schuerer at gmx dot at
 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=35540



More information about the Gcc-bugs mailing list