gcc version 2.96 (CVS, from 20000203, Linux): Bug with -O1
Daniel Lauer
daniel@informatik.uni-bonn.de
Wed Feb 9 05:09:00 GMT 2000
Hello,
the compiler
GNU C version 2.96 (CVS version from Feb 3, 2000)
makes wrong assembler code when compiling the following C-Code with -O1.
There is no error compiling it with -O0.
This error does NOT occur when compiling with
- gcc version 2.95.2 19991024 (release)
or - gcc version 2.8.1
or - gcc version 2.7.2.3
or - gcc version 2.7.2.1
Daniel Lauer,
Bonn, Germany, 2000, Feb 09
Appendix:
- C source 'bug.c'
- output of verison '-O1'
- output of verison '-O0'
-- C source 'bug.c' -----------------------------------------------------
unsigned int buggy (unsigned int *param) {
unsigned int accu, zero=0, borrow;
accu = - *param;
borrow = - (accu > zero);
*param += accu;
return borrow;
}
int main (int i, char **c) {
unsigned int param = 1;
printf ("Value must be zero: %ld\n", 1 + buggy( ¶m ) );
return 0;
}
-------------------------------------------------------------------------
-- output of 'gcc -v -O1 bug.c; a.out' ----------------------------------
Reading specs from
/usr/local/gcc-20000203/lib/gcc-lib/i586-pc-linux-gnu/2.96/specs
gcc version 2.96 20000203 (experimental)
[...]
Value must be zero: 1
-------------------------------------------------------------------------
-- output of 'gcc -v -O0 bug.c; a.out' ----------------------------------
Reading specs from
/usr/local/gcc-20000203/lib/gcc-lib/i586-pc-linux-gnu/2.96/specs
gcc version 2.96 20000203 (experimental)
[...]
Value must be zero: 0
-------------------------------------------------------------------------
More information about the Gcc-bugs
mailing list