public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8963: The same template instance is mangled with 2 different names
@ 2002-12-16 11:16 catherin
  0 siblings, 0 replies; only message in thread
From: catherin @ 2002-12-16 11:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8963
>Category:       c++
>Synopsis:       The same template instance is mangled with 2 different names
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 16 11:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Catherine Morton
>Release:        gcc 3.2
>Organization:
>Environment:
g++ -v
Reading specs from /usr/lib/gcc-lib/powerpc-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit powerpc-suse-linux
Thread model: posix
gcc version 3.2
>Description:
Example:

// ---------------- a.cpp ---------------------
#include "def.h"

const int thirty = 30;
template <int J, int K> void stuff( thing<(signed char)(thirty)> x) {}

void great()
{
stuff<7,8>(9);
}
// --------------------------------------------

// ---------------- b.cpp ---------------------
#include "def.h"

const int thirtx = 30;
template <int J, int K> void stuff( thing<(unsigned char)(thirtx)> x);

int main()
{
  stuff<7,8>(9);
}
// --------------------------------------------

// ------------- def.h ------------------------

template <int> struct thing {thing(int){} };

// --------------------------------------------

In this example, there is one template instantiation for template thing which is thing<30>
However, using gcc, there are 2 different mangled names:
a.o
_Z5stuffILi7ELi8EEv5thingIXcvaL_Z6thirtyEEE

b.o
_Z5stuffILi7ELi8EEv5thingIXcvhL_Z6thirtxEEE

Because of this problem, g++ will get a link error from this testcase
g++ a.cpp b.cpp

/nfs/protoss/home/catherin/tmp/ccmWazir.o: In function `main':
/nfs/protoss/home/catherin/tmp/ccmWazir.o(.text+0x30): undefined reference to `void stuff<(int)7, (int)8>(thing<operator unsigned char(thirtx)>)'
/nfs/protoss/home/catherin/tmp/ccmWazir.o(.text+0x30): relocation truncated to fit: R_PPC_REL24 void stuff<(int)7, (int)8>(thing<operator unsigned char(thirtx)>)
collect2: ld returned 1 exit status
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-16 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-16 11:16 c++/8963: The same template instance is mangled with 2 different names catherin

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).