From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BE1193858D1E; Wed, 17 May 2023 09:00:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE1193858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684314051; bh=h4zr24xWr0rR7K933LeuJQuhyBeQcD4IM3aevPuNf1E=; h=From:To:Subject:Date:From; b=F16HfnoS4dp7HK6UQoE39RuAxaUIMX/PP7t8AXFrSBe+RjlBKM6qscg3Wcd/aDmdO UbWkr8d11JepAOLnwiI9gHgFOykhdN7fVvbzN0xofx7/fx+bVVyB7I4pannMz7tY2K 01wJ7/GIZT+7oflGrPV7+DAl7U4/fbdCZkxgdnv0= From: "yedeng.yd at linux dot alibaba.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109887] New: Different mangled name for template specialization for clang and gcc Date: Wed, 17 May 2023 09:00:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yedeng.yd at linux dot alibaba.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109887 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 namespace llvm { class StringRef { public: StringRef(const char*); }; template class Optional {}; } namespace n { struct S { template std::enable_if_t::value, llvm::Optional> get(llvm::StringRef) const { return {}; } }; template <> llvm::Optional S::get(llvm::StringRef) const; } void use() { n::S().get("hello"); } ``` For the specialization `S::get(llvm::StringRef)`, gcc will mangle it = as: ``` _ZNK1n1S3getIbEENSt9enable_ifIXsrSt11is_integralIT_E5valueEN4llvm8OptionalI= S4_EEE4typeENS6_9StringRefE ``` and clang will mangle it as: ``` _ZNK1n1S3getIbEENSt9enable_ifIXsr3std11is_integralIT_EE5valueEN4llvm8Option= alIS3_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 cl= ang and gcc are trying to make ABI compatible.=