Search code examples
c++declarationlanguage-lawyerdefinitionextern

Program with extern decl-specifier in a class definition


Consider the following program:

extern class A;

int main() {}

Is this well-formed according to the c++ standard? If it is ill-formed is diagnostics required? I'm getting different results for different compilers:


Solution

  • The program is ill-formed according to §7.1.1/1:

    If a storage-class-specifier appears in a decl-specifier-seq, […] the init-declarator-list of the declaration shall not be empty (except for an anonymous union declared in a named namespace or in the global namespace, which shall be declared static (9.5)).