Reputation: 21160
Inspired by this question, I had a look around the standard. There is a note in [class.abstract]
[Note: An abstract class type cannot be used as a parameter or return type of a function being defined ([dcl.fct]) or called ([expr.call]), except as specified in [dcl.type.simple]. [...]
For definitions [dcl.fct.def.general]
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 ([dcl.fct.def.delete]).
But I couldn't find anything about declarations, by which I can only conclude there is nothing wrong with it.
Upvotes: 1
Views: 116
Reputation: 21160
This is P0929. Prior to C++20, function declarations are also ill-formed, but it lead to surprising semantics. Suppose
struct S;
S foo(); // 1
struct S { virtual void bar() = 0; }; // 2
At 1
, the function is well-formed, yet 2
retroactively made it ill-formed. This is highly unintuitive, and so was changed.
Upvotes: 2