* [gcc-3.0 bug?] C++ symbols treated as C
@ 2001-04-22 22:34 Andrey Slepuhin
2001-04-24 3:29 ` Andrey Slepuhin
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Slepuhin @ 2001-04-22 22:34 UTC (permalink / raw)
To: gcc
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [gcc-3.0 bug?] C++ symbols treated as C
2001-04-22 22:34 [gcc-3.0 bug?] C++ symbols treated as C Andrey Slepuhin
@ 2001-04-24 3:29 ` Andrey Slepuhin
0 siblings, 0 replies; 2+ messages in thread
From: Andrey Slepuhin @ 2001-04-24 3:29 UTC (permalink / raw)
To: gcc
On Mon, Apr 23, 2001 at 09:34:15AM +0400, Andrey Slepuhin wrote:
> 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:
[snip]
Ok, I found a test case which localizes a problem.
Compiling the following program with 20010422 snapshot:
-------------------------------------------------------
#include <cstdio>
namespace A
{
int abcdef;
template <typename val_t>
class X
{
public:
inline X ()
{
extern int abcdef;
printf("%d\n", abcdef);
}
};
}
using namespace A;
int main (int argc, char* argv[])
{
X<int> x;
return 0;
}
------------------------------------------------------------
I got the following error:
/tmp/ccWmhmdS.o: In function `A::X<int>::X()':
/tmp/ccWmhmdS.o(.gnu.linkonce.t._ZN1A1XIiEC1Ev+0xb): undefined reference to
`abcdef'
collect2: ld returned 1 exit status
Assembler output shows that "extern int abcdef;" is not considered as a member
of namespace A. 20010311 snapshot compiles this program without errors.
Making X non-template class also removes errors.
Regards,
Andrey.
--
A right thing should be simple (tm)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-04-24 3:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-22 22:34 [gcc-3.0 bug?] C++ symbols treated as C Andrey Slepuhin
2001-04-24 3:29 ` Andrey Slepuhin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).