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/35798] New: Segmentation Fault launched when compiling with optimization level>0 -O1, -O2, ...


#include <stdlib.h>

#define N 50
void test(void) {
        static char *array=NULL;
        int i;

        if (array==NULL) {
                array=calloc(N, sizeof(char));
                array[0]=0;
                for(i=1;i<N;i++) {
                        if (rand()%2==0) array[i]=array[i-1];
                        else array[i]=1+array[i-1];
                }
        }
}

/******************************************************************************
Segmentation Fault launched when compiling with optimization level>0 -O1, -O2,
...:
> "C:\Dev-Cpp\bin\gcc.exe" "segfault.c" -o "segfault.exe" -O3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
segfault.c: In function `test':
segfault.c:16: internal compiler error: Segmentation fault
Please submit a full bug report, with preprocessed source if appropriate.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.

OS version: Windows XP SP2 32-bits
gcc version: 3.4.2 (mingw-special)
ld version: GNU ld version 2.15.91 20040904
mingw version: 3.7
build environment: Dev-C++ v4.9.9.2
No MSYS
mingw-runtime version: 3.7
w32api version: 3.2

> "C:\Dev-Cpp\bin\gcc.exe" -v
Reading specs from C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as
--host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls
--enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared
--e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x
--enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter
--enable-hash-synchroniz
ation --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.2 (mingw-special)

> "C:\Dev-Cpp\bin\ld" -v
GNU ld version 2.15.91 20040904

> Compiled with Dev-C++ v4.9.9.2

I am not sure if this bug is the same that was reported here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24791

Just in case, I am going to report it:
http://gcc.gnu.org/bugzilla/enter_bug.cgi

I have try to reproduce the bug under Linux, but I couldn't, at least compiling
with gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) ...

It might be only a gcc 3.4.x bug ...
******************************************************************************/


-- 
           Summary: Segmentation Fault launched when compiling with
                    optimization level>0 -O1, -O2, ...
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bankhacker at gmail dot com
 GCC build triplet: "C:\Dev-Cpp\bin\gcc.exe" "segfault.c" -o "segfault.exe"
                    -O3 -I"C
  GCC host triplet: Windows XP SP2 32-bits
GCC target triplet: segfault.c


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


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