Consider the following example:
struct A {
using type = int;
};
template <typename T>
using B = A;
template <typename T>
typename B<T>::type f() { return {}; }
template B<int>::type f<int>();
Clang generates symbol named int f<int>()
while GCC generates B::type f<int>()
for the instantiation: https://godbolt.org/z/MCCza4
Why don't the compilers agree and shouldn't GCC also resolve B::type
to int
?
Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.
Clang is designed to provide a frontend compiler that can replace GCC. Apple Inc. (including NeXT later) has been using GCC as the official compiler. GCC has always performed well as a standard compiler in the open source community.
TL;DR: Clang is highly compatible to GCC - just give it a go. In most cases, Clang could be used as a GCC drop in replacement ( clang and clang++ are "GCC compatible drivers").
This is a known C++ CWG (Core Working Group) issue: https://wg21.cmeerw.net/cwg/issue2037, quoting Richard Smith:
On the one hand, the alias template can introduce SFINAE conditions, so it should be instantiation-dependent and mangled. On the other hand, the language rules permit this template to be redeclared using the result of expanding the alias template, so mangling it can't be correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With