Different compilers show different behavior compiling the following code:
namespace N
{
namespace Foo
{
template <typename>
struct Foo
{
};
}
}
template <typename Type>
using Foo = N::Foo::Foo<Type>;
namespace N
{
template <typename Type>
struct Bar : Foo<Type>
{
};
}
int main()
{
}
Compilers tested and their compilation flags:
- clang++ 5.0.0:
-std=c++14 -Wall -Wextra -Werror -pedantic-errors - g++ 7.2:
-std=c++14 -Wall -Wextra -Werror -pedantic-errors - vc++ 19.10.25017 (VS 2017):
/EHsc /Za /std:c++14 /permissive- - icc 18.0.0:
-std=c++14 -Wall -Werror
Results of the compilation:
clang++:
18 : <source>:18:15: error: expected class name struct Bar : Foo ^g++: successful compilation
vc++:
18 : <source>(18): error C2516: 'Foo': is not a legal base class 13 : <source>(13): note: see declaration of 'Foo' 20 : <source>(20): note: see reference to class template instantiation 'N::Bar<Type>' being compiled 18 : <source>(18): error C2143: syntax error: missing ',' before '<'icc: successful compilation
Which compiler behavior is standard compliant?
Additional information: