public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109887] New: Different mangled name for template specialization for clang and gcc
@ 2023-05-17  9:00 yedeng.yd at linux dot alibaba.com
  2023-05-17 10:13 ` [Bug c++/109887] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: yedeng.yd at linux dot alibaba.com @ 2023-05-17  9:00 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-10-05 22:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17  9:00 [Bug c++/109887] New: Different mangled name for template specialization for clang and gcc yedeng.yd at linux dot alibaba.com
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

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).