Consider the following code:
template <typename> struct S { S(); };
// extern template struct S<int>;
template <typename T> S<T>::S() = default;
template S<int>::S();
clang++
happily accepts this code.
g++
complains with:
error: definition of explicitly-defaulted 'S< <template-parameter-1-1> >::S()
[with <template-parameter-1-1> = int]'
3 | template <typename T> S<T>::S() = default;
| ^~~~
Uncommenting the extern template
fixes compilation with g++
(and clang++
is still happy).
Is g++
correct in rejecting the code?