[c++] builtins, std::sin now recursive
Benjamin Kosnik
bkoz@redhat.com
Thu Oct 26 07:20:00 GMT 2000
Jason.
The following code is now failing.
extern "C" {
extern double sin(double);
}
namespace std {
inline double
sin(double __x) { return ::sin(__x); }
}
int main()
{
std::sin(0);
sin(0);
return 0;
}
Note that this fails with -O2, -O, etc because ........ it gives a
infinitely recursive call:
.file "math-fail.cc"
.version "01.01"
gcc2_compiled.:
.text
.align 16
.globl main
.type main,@function
main:
.LFB1:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
subl $16, %esp
.LCFI2:
pushl $0
pushl $0
.LCFI3:
call sin // should be inlined to ::sin
fstp %st(0)
popl %eax
popl %edx
pushl $0
pushl $0
call sin // should be inlined to ::sin
fstp %st(0)
xorl %eax, %eax
movl %ebp, %esp
popl %ebp
ret
.LFE1:
.Lfe1:
.size main,.Lfe1-main
.section .gnu.linkonce.t.sin,"ax",@progbits
.align 16
.weak sin
.type sin,@function
sin: // ::sin, should be std::sin
.LFB2:
pushl %ebp
.LCFI4:
movl %esp, %ebp
.LCFI5:
subl $8, %esp
.LCFI6:
movl %ebp, %esp
popl %ebp
.LCFI7:
jmp sin // ::sin
.LFE2:
.Lfe2:
.size sin,.Lfe2-sin
.ident "GCC: (GNU) 2.97 20001024 (experimental)"
Can you please look at this?
thanks,
benjamin
More information about the Gcc-bugs
mailing list