public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yedeng.yd at linux dot alibaba.com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-109887-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-05-17  9:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17  9:00 yedeng.yd at linux dot alibaba.com [this message]
2023-05-17 10:13 ` [Bug c++/109887] " redi at gcc dot gnu.org
2023-05-17 10:15 ` redi at gcc dot gnu.org
2023-05-17 10:19 ` jakub at gcc dot gnu.org
2023-10-05 22:32 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109887-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).