This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in g++ name mangling




Hi,

I found what I think is a minor bug in g++'s  name mangling. In
summary depending on the context, the same function gets mangled in 2
different ways. Thus if these 2 different ways happen in 2 separate
compilation units undefined symbols result. The real culprit seems to
be
seeing the identical typedefs twice, which I think is allowed by
C++. The workaround is to make sure that there's only 1 typedef.


$ g++ -v
Reading specs from
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

*********A.i*****

typedef int I;
 
class A
{
public:
  A(const I&, const int&);
};
 
 
A::A(const I&, const int&)
{}

**********main.i*******
typedef int I;
typedef int I;
 
class A
{
public:
  A(const I&, const int&);
};
 
int main()
{
  I i;
  A a(i,i);
}

***********
$ g++ A.i main.i
/tmp/ccrbCpmi.o: In function `main':
/tmp/ccrbCpmi.o(.text+0x13): undefined reference to `A::A(int const &, 
int const &)'
collect2: ld returned 1 exit status

$ nm main.o
         U __1ARCiT1
00000000 ? __FRAME_BEGIN__
00000000 t gcc2_compiled.
00000000 T main
$ nm A.o
00000000 T __1ARCiRCi
00000000 ? __FRAME_BEGIN__
00000000 t gcc2_compiled.



Thanks a lot,
Vadim 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]