There is this code:
class A;
template
void fun() {
A a;
}
class A {
public:
A() { }
};
int main() {
fun();
return
Which compiler is right then according to C++ standard?
Both are correct. This is an ill-formed program. Emphasis mine:
N3290 14.6¶9
If a type used in a non-dependent name is incomplete at the point at which a template is defined but is complete at the point at which an instantiation is done, and if the completeness of that type affects whether or not the program is well-formed or affects the semantics of the program, the program is ill-formed; no diagnostic is required.
That clang++ and other compilers do issue a diagnostic here is a nice-to-have added feature, but a diagnosis is not mandatory. That clause "the program is ill-formed; no diagnostic is required" gives a compiler developer free reign to do just about anything in such circumstances and still be compliant.