struct A{
virtual void fun() = 0;
};
extern A a; //#1
void foo(A); //#2
int main(){}
The declarations at #1 and #2 are both complained as invalid declarations by GCC and Clang. The result is here.
However according to the current draft, it does not explicitly forbid this usage. What it states are just in the following
[basic.def#5]
In the definition of an object, the type of that object shall not be an incomplete type ([basic.types]), an abstract class type, or a (possibly multi-dimensional) array thereof.
In my example, the object a at #1 and the unnamed parameter at #2 are merely declarations rather than definitions, as per
[basic.def#2]
Each entity declared by a declaration is also defined by that declaration unless:
- it contains the extern specifier or a linkage-specification19 ([dcl.link]) and neither an initializer nor a function-body,
- it is a parameter-declaration in a function declarator that is not the declarator of a function-definition
The other place limits the usage of abstract class type related to this example is section [dcl.fct.def]
The type of a parameter or the return type for a function definition shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body unless the function is deleted
In other words, it does not limit the usage of abstract class type in a function declaration that is not a definition.
So, according to the behavior of the compilers, Could it say that, in the declaration of an object, the type of that object shall not be an abstract class type? If I miss some normative rule that limits the usage of abstract class type, please point it out.