Consider the following c++ program:
struct S;
template<typename T>
void f() {
S s;
}
struct S
{
};
int main()
{
f<void>();
}
When compiling the above c++ program with clang and gcc using "-std=c++17 -pedantic-errors" they behave differently. The compilation with clang fails with an error message about the type 'S' not being complete. Gcc compiles it without any errors messages.
Note that I did not instansiate f until the type S was complete.
What does the c++ standard say about this program? Is this a bug in clang or gcc or are both behaviours acceptable by the c++ standard?
Link to compiler explorer: https://godbolt.org/z/o6hro1