[gcc-3.0 bug?] C++ symbols treated as C
Andrey Slepuhin
pooh@msu.ru
Sun Apr 22 22:34:00 GMT 2001
Hi,
Trying to upgrade from 20010311 to 20010419 gcc snapshot
(taken from CodeSourcery) I got undefined references
when linking my C++ code. Looking into assembler output I see the
things like following:
movl _ZN5grace16shared_allocatorE, %eax
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
movl (%eax), %ecx
pushl $16
pushl %eax
.LCFI4:
call *8(%ecx)
movl %eax, %ebx
addl $16, %esp
testl %ebx, %ebx
jne .L3
subl $12, %esp
pushl $132
pushl $.LC0
pushl $_ZZN5grace5T_ValIiEnwEjE19__PRETTY_FUNCTION__
pushl $.LC1
pushl stderr
.LCFI5:
call fprintf
addl $20, %esp
pushl $.LC2
.LCFI6:
call _ZN3pxx5fatalEPcz
addl $16, %esp
.L3:
.LBE4:
.LBE3:
.LEHB5:
subl $10, %esp
pushw $0
pushl %ebx
call _ZN5grace5T_ValIiEC1Eb
.LEHE5:
addl $16, %esp
.stabs "test.cc",132,0,0,.Ltext2
.Ltext2:
.stabn 68,0,13,.LM3-_Z5tmainiPPc
.LM3:
xorl %eax, %eax
movl -4(%ebp), %ebx
leave
ret
.LBE2:
.p2align 2
.L5:
.LEHB13:
movb $1, %dl
testb %dl, %dl
je .L7
.stabs "../src/gr_tval.hh",132,0,0,.Ltext3
.Ltext3:
.stabn 68,0,135,.LM4-_Z5tmainiPPc
.LM4:
subl $8, %esp
movl shared_allocator, %eax
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
movl (%eax), %ecx
pushl %ebx
pushl %eax
call *12(%ecx)
addl $16, %esp
.L7:
subl $12, %esp
pushl $.LRTH5
call __rethrow
.p2align 2
.L13:
.LEHE13:
.LCFI7:
call _ZSt9terminatev
Note that in lower part of code symbol `shared_allocator' looks like
C symbol. 20010311 snapshot produces correct mangled C++ name in that
place. What may be wrong in this situation?
Appropriate C++ code looks like this:
#include "gr_shared_allocator.hh"
template <typename val_t>
class T_Val
{
.....
void* operator new (size_t _size) \
{
void* p = shared_allocator->allocate(_size);
if (p == null) FATAL("Memory allocation failed");
return p;
}
......
};
int tmain (int argc, char* argv[])
{
T_Val<int>* p = new T_Val<int>;
return 0;
}
where template class T_Val has overloaded new() operator:
Yes, I'm 100% sure that all declarations are done in proper places.
If needed, I can send actual .ii output but it is rather large.
Regards,
Andrey.
--
A right thing should be simple (tm)
More information about the Gcc
mailing list