[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

gcc-3.0 optimization bug on debian GNULinux on x86 with very simple program



>Submitter-Id:	net
>Originator:	Thomas Deselaers
>Organization:	
>Confidential:	no
>Synopsis: gcc-3.0 optimization bug on debian GNU/Linux on x86 with very simple program	
>Severity:	non-critical
>Priority:	medium
>Category:	c
>Class:	 wrong-code	
>Release:	3.0.4 (Debian testing/unstable)
>Environment:
System: Linux racker 2.4.19 #3 Tue Aug 6 23:01:23 CEST 2002 i686 unknown unknown GNU/Linux
Architecture: i686

Dell Inspiron 8200, Pentium 4 mobile 1600
OS: Linux 2.4.19 unpatched

host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:

OK, while playing around(together with Stefan Jacobs, he wanted to be 
mentioned) I found out, that this small programm:

-------file:maxint.cc------------
main() {
      int i=0;
      int oldi=0;;
      while(++i>oldi) oldi=i;
      return oldi;
}
---------------------------------

does work absolutely fine, when compiled without any optimization, 
but does not terminate at all, when using any optimization-options:

with "gcc -o maxint maxint.cc" the maxint-program works fine, but
with "gcc -o maxint maxint.cc -O$X" with $X being nothing, or one of 
the numbers from 1 to 9, the maxint program does not terminate.


>How-To-Repeat:

copy the code-excerpt to a file and compile it

>Fix:
Workaround: not use -O$X



Reply to: