gcc -v output : **************** Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux Thread model: posix gcc version 3.3.3 (Debian 20040429) **************** I was writing a fonction "isnumber" to find is a string is a number. So I used strtol, but I made a mistake, which produce the text : **************** isnumber.c: In function `isnumber': isnumber.c:14: error: Attempt to delete prologue/epilogue insn: (insn/f 80 79 81 0 (nil) (set (mem:SI (plus:SI (reg/f:SI 6 ebp) (const_int -4 [0xfffffffc])) [0 S4 A8]) (reg:SI 3 ebx)) -1 (nil) (nil)) isnumber.c:14: internal compiler error: in propagate_one_insn, at flow.c:1642 Please submit a full bug report, **************** After some tests, I found that this is produce only with some kinds of -O optimization.. I have extracted two examples that doesn't compile : **************** /* gcc flag * -O0 : works * -O1 : works * -O2 : doesn't work * -O3 : doesn't work */ int isnumber1_bug(const char *chaine) { char *endptr[1]; endptr[1] = '\0'; strtol(chaine,endptr,10); return *chaine != '\0' && **endptr == '\0'; } **************** /* gcc flag * -O0 : works * -O1 : doesn't work * -O2 : doesn't work * -O3 : doesn't work */ int isnumber2_bug(const char *chaine) { char *endptr[1]; endptr[1] = '\0'; strtol(chaine,(char **)NULL,10); return *chaine != '\0'; } **************** of course, the right way is to write "*endptr[1] = '\0';", that was my mistake... but what is strange is that this : **************** /* this works ! */ int isnumber1(const char *chaine) { char *endptr[1]; endptr[1] = '\0'; strtol(chaine,endptr,10); return **endptr == '\0'; } **************** ..is working : just the last line changed... How-To-Repeat: just with "gcc -O2 -c -o isnumber.o isnumber.c", and try with other -O optimization flags... ;-]
Created attachment 6341 [details] All sources, .i file, output compilation
Confirmed, of course this is all undefined code.
Adjust milestone
won't fix for 3.3.6. Works in 3.4.0 and higher.