The following program:
template<typename = void>
const int n;
is compiled successfully by gcc, but clang gives an error:
# error: default initialization of an object of const type 'const int'
const int n;
^
= 0
which makes sense.
gcc does give an error if n
is used, but is a diagnostic required even if n
is unused?
No. The applicable rule is [temp.res.general]/8:
So both compilers are complying with the Standard.