https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109887
Bug ID: 109887 Summary: Different mangled name for template specialization for clang and gcc Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yedeng.yd at linux dot alibaba.com Target Milestone: --- (This is a duplication of https://github.com/llvm/llvm-project/issues/62765 since I don't know which one is worse) Reproducer: ``` #include <type_traits> namespace llvm { class StringRef { public: StringRef(const char*); }; template <typename T> class Optional {}; } namespace n { struct S { template <class T> std::enable_if_t<std::is_integral<T>::value, llvm::Optional<T>> get(llvm::StringRef) const { return {}; } }; template <> llvm::Optional<bool> S::get<bool>(llvm::StringRef) const; } void use() { n::S().get<bool>("hello"); } ``` For the specialization `S::get<bool>(llvm::StringRef)`, gcc will mangle it as: ``` _ZNK1n1S3getIbEENSt9enable_ifIXsrSt11is_integralIT_E5valueEN4llvm8OptionalIS4_EEE4typeENS6_9StringRefE ``` and clang will mangle it as: ``` _ZNK1n1S3getIbEENSt9enable_ifIXsr3std11is_integralIT_EE5valueEN4llvm8OptionalIS3_EEE4typeENS4_9StringRefE ``` Also the c++filt can only recognize the name mangled by gcc. And the llvm-cxxfilt can only recognize the name mangled by clang. So I am not sure if this is bug really or this is by design. But I think clang and gcc are trying to make ABI compatible.