Consider the following c++ program:
template<typename X>
struct S
{
X x;
};
template<typename>
void f()
{
S<void> s;
}
int main()
{
}
When compiled with "-std=c++17 -pedantic-errors" it gives a compilation error with clang, but gives no compilation errors with gcc.
What does the c++ standard say about this program? Is it valid or not? In case it is invalid, does it have undefined behaviour?
If the person that answers this could go ahead and include the relevant parts of the c++ standard in their answer that would be great.
Compiler explorer link to try this out: https://godbolt.org/z/Ke1K7b
f()
is never instantiated. addf<int>();
to main. – Richard Critten Sep 7 '20 at 18:33