[cfe-dev] Inconsistent IA-64 name mangling between gcc and Clang for template functions with a local class template parameter
Tom Honermann
thonermann at coverity.com
Mon Jun 4 14:01:03 PDT 2012
I recently happened along code for which gcc and Clang generate
different IA-64 external names. A test case follows. The name in
question is for the template specialization of 'foo' parametrized with
local class 'Item' of 'X<int>::test<char>(char&) const'
$ cat test.cpp
template<typename T>
const T *foo(const T &t) {
return &t;
}
template<typename T>
struct X {
template<typename U>
void test(U &) const {
struct Item {} x;
foo(x);
}
};
int main() {
X<int> x;
char c;
x.test(c);
}
$ g++ --version
g++ (GCC) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ -std=c++0x -c test.cpp
$ nm test.o | grep foo
00000000 W _Z3fooIZNK1XIiE4testIcEEvRT_E4ItemEPKT_RS7_
$ clang --version
clang version 3.1 (branches/release_31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ clang -std=c++0x -c test.cpp
$ nm test.o | grep foo
0000000000000020 t _Z3fooIZNK1XIiE4testIcEEvRT_E4ItemEPKS3_RS6_
For ease of comparison, that's:
_Z3fooIZNK1XIiE4testIcEEvRT_E4ItemEPKT_RS7_ (gcc)
_Z3fooIZNK1XIiE4testIcEEvRT_E4ItemEPKS3_RS6_ (clang)
It seems that Clang is implementing a substitution candidate that gcc is
not. My reading of the IA-64 ABI specification
(http://sourcery.mentor.com/public/cxx-abi/abi.html) leaves me unclear
as to what the correct mangling should be.
Tom.
More information about the cfe-dev
mailing list