This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 108i. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2022-07-16


135. Class type in in-class member function definitions

Section: 9.3.4.6  [dcl.fct]     Status: TC1     Submitter: Gabriel Netterdag     Date: 1 July 1999

6.3 [basic.def.odr] paragraph 4 and 9.3.4.6 [dcl.fct] paragraph 6 indicate that the return type and parameter types must be complete in a function definition. However, when 11.4 [class.mem] paragraph 2 lists the contexts in a class member-specification in which the class is considered complete, the return type and parameter types of a member function defined in the class definition are not included. It thus appears that the following example is ill-formed:

    struct S {
        S f() { return S(); }    // error: incomplete return type
        void g(S) { }            // error: incomplete parameter type
    };
Jack Rouse: I suggest supplementing the text in 8.3.5p6 with something like:
The type of a parameter or the return type for a function definition shall not be an incomplete class type unless the function definition is nested in the member-specification for that class (including definitions in nested classes defined within the class).

Proposed resolution (10/00): Replace the last sentence of 9.3.4.6 [dcl.fct] paragraph 6 with

The type of a parameter or the return type for a function definition shall not be an incomplete class type (possibly cv-qualified) unless the function definition is nested within the member-specification for that class (including definitions in nested classes defined within the class).