Mangling difference between GCC and clang

@dmitry discovered a case where gcc and Clang mangle a function name differently: Compiler Explorer (reduction courtesy of @bcardosolopes). The function has the return type std::enable_if_t<std::is_integral<T>::value, T>. The first line is the gcc mangling, the second is the Clang mangling:

_Z4funcIbENSt9enable_ifIXsrSt11is_integralIT_E5valueES2_E4typeEv
_Z4funcIbENSt9enable_ifIXsr3std11is_integralIT_EE5valueES1_E4typeEv

The difference is that gcc mangles the inner std::is_integral as St11is_integral, whereas Clang manges it as 3std11is_integral (i.e. it’s not abbreviating the std::). Does anyone know why the manglings differ here? I couldn’t find a Clang test case covering this scenario.

Interestingly enough, GNU c++filt can’t demangle the Clang mangled name, and llvm-cxxfilt can’t demangle the gcc mangled name, so there seems to be some ecosystem-wide disagreement here.

5 Likes

This is Different mangled name for template specialization for clang and gcc · Issue #62765 · llvm/llvm-project · GitHub

1 Like