int f() { return 0; } template <typename T, typename... U> int f(T t, U... u) { return (t ? 1 : 0) * sizeof...(U) + f(u...); }
int main() { return f(1, 1.0, 2); } has 3 mangled names, but 2 of them demangle weirdly (I'd say we should demangle U10__variadic to something containing ..., not __variadic) and one doesn't demangle at all: #include <cxxabi.h> #include <iostream> int main () { char buf[128]; size_t len; int status; len = sizeof (buf); status = 0; abi::__cxa_demangle ("_Z1fIdiEiT_U10__variadicT0_", buf, &len, &status); std::cout << buf << " " << len << " " << status << std::endl; abi::__cxa_demangle ("_Z1fIiEiT_U10__variadicT0_", buf, &len, &status); std::cout << buf << " " << len << " " << status << std::endl; abi::__cxa_demangle ("_Z1fIidiEiT_U10__variadicT0_", buf, &len, &status); std::cout << buf << " " << len << " " << status << std::endl; } G++ in all cases mangles the variadic arg as U10__variadicT0_, as the variadic template parameter is 2nd, but that parameter is never mangled among the I parameters and so the demangler considers it out of range and refuses to demangle it. Not mentioning the parameter packs in the I list IMHO has a bigger effect than just having out of range U10__variadic template parameter types. As for functions the parameter packs don't need to be at the end of template argument list, we get out of range mangling even for say: template <typename T, typename... U, typename W, typename ... V> int foo (T a, W b) { return a + b; } int bar (void) { return foo (1, 2); } _Z3fooIiiEiT_T1_ -- Summary: Demangling of variadic functions Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: ABI Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37718