This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/13472] New: optimizer generates code to store data in const int, resulting in a segfault


When the attached program is compiled with the following options:

dogbert> gcc -v -pedantic -march=i686 -O2 r.c
Reading specs from /usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: ../gcc/configure --prefix=/usr/local/gcc333
--enable-languages=c,c++,f77
Thread model: posix
gcc version 3.3.3 20031223 (prerelease)
 /usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/cc1 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 r.c -quiet -dumpbase r.c
-march=i686 -auxbase r -O2 -pedantic -version -o /tmp/cccX38fK.s
GNU C version 3.3.3 20031223 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.3 20031223 (prerelease).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128958
ignoring nonexistent directory "/usr/local/gcc333/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/gcc333/include
 /usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include
 /usr/include
End of search list.
 as -V -Qy -o /tmp/ccgjNrLm.o /tmp/cccX38fK.s
GNU assembler version 2.14.90.0.5 (i586-suse-linux) using BFD version
2.14.90.0.5 20030722 (SuSE Linux)
 /usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/collect2 --eh-frame-hdr
-m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtbegin.o
-L/usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3
-L/usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/../../.. /tmp/ccgjNrLm.o
-lgcc -lgcc_eh -lc -lgcc -lgcc_eh
/usr/local/gcc333/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/crtend.o /usr/lib/crtn.o
dogbert> a.out
Segmentation fault

All command line parameters are essential to produce the bug (including
-pedantic; I wasn't aware that this switch affected code generation...).

The bug is triggered for all of the following platforms: i686, pentium2, athlon,
athlon-tbird.

The bug occurs with gcc 3.3.3, 3.3.2 and 3.3.1, but not with gcc 3.2.3.

Upon inspecting the assembler output it appears that the optimizer generates
code that tries to overwrite the const int q.

-- 
           Summary: optimizer generates code to store data in const int,
                    resulting in a segfault
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: p dot van-hoof at qub dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 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=13472


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]