mrtd bug
Konstantin Boldyshev
konst@voshod.com
Wed Aug 25 02:05:00 GMT 1999
Hello,
It seems that there's a bug in egcs-2.91.57 / i386/ Linux.
If have a simple function like:
double calc_max(double x,double y)
{
return x>y?x:y;
}
and compile it with 'gcc -S -c -O1 sample.c':
.file "SAMPLE.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
.align 4
.globl _calc_max__Fdd
.def _calc_max__Fdd; .scl 2; .type 32; .endef
_calc_max__Fdd:
pushl %ebp
movl %esp,%ebp
fldl 8(%ebp)
fldl 16(%ebp)
fcom %st(1)
fnstsw %ax
andb $69,%ah
cmpb $1,%ah
jne L5
fstp %st(0)
jmp L2
L5:
fstp %st(1)
L2:
movl %ebp,%esp
popl %ebp
ret
But if we compile this code with 'gcc -S -c -O1 -mrtd sample.c'
we get the following:
.file "SAMPLE.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
.align 4
.globl _calc_max__Fdd
.def _calc_max__Fdd; .scl 2; .type 32; .endef
_calc_max__Fdd:
pushl %ebp
movl %esp,%ebp
fldl 8(%ebp)
fstp %st(0)
movl %ebp,%esp
popl %ebp
ret $16
that is absolutely wrong.
Another man reported that the same happens with -mregparm=3
but I failed to reproduce it on my machine.
This code compiles fine with -mrtd in gcc-2.8.1
Haven't tested it on 2.95.x.
Regards,
Konstantin.
More information about the Gcc-bugs
mailing list