Title
Syntactic specification of class completeness
Status
c++23
Section
11.4.1 [class.mem.general]
Submitter
Jim X

Created on 2022-07-04.00:00:00 last changed 9 months ago

Messages

Date: 2022-11-10.14:54:29

Proposed resolution (approved by CWG 2022-11-09):

Change in 11.4.1 [class.mem.general] paragraph 8 as follows:

A class is considered a completely-defined object type (6.8.1 [basic.types.general]) (or complete type) at the closing } of the class-specifier. The A class is regarded as complete where its definition is reachable and within its complete-class contexts; otherwise it is regarded as incomplete within its own class member-specification.
Date: 2022-11-10.14:54:29

CWG telecon 2022-10-21:

Explicitly refer to reachable definitions.

Date: 2022-11-15.00:00:00

[Accepted as a DR at the November, 2022 meeting.]

Consider:

// translation unit 1
export module A;
export class X {};

// translation unit 2
import A;
X x; // is X complete at this point?

Subclause 11.4.1 [class.mem.general] paragraph 8 specifies:

A class is considered a completely-defined object type (6.8.1 [basic.types.general]) (or complete type) at the closing } of the class-specifier. ...

The syntactic (even lexical) reference to the closing } does not address the question when a different translation unit regards a class as complete. However, it seems this provision is entirely redundant given 6.3 [basic.def.odr] paragraph 13:

A definition of a class shall be reachable in every context in which the class is used in a way that requires the class type to be complete.

The standard never asks the question: "Is class X complete?"; it always specifies "X shall be complete" (otherwise the program is ill-formed).

Possible resolution [SUPERSEDED]:

Change in 11.4.1 [class.mem.general] paragraph 8 as follows:

A class is considered a completely-defined object type (6.8.1 [basic.types.general]) (or complete type) at the closing } of the class-specifier. The A class is regarded as complete within its complete-class contexts; otherwise it is regarded as incomplete within its own class member-specification.
History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: ready -> dr
2022-11-10 14:54:29adminsetstatus: review -> ready
2022-11-10 14:54:29adminsetmessages: + msg7015
2022-11-10 14:54:29adminsetstatus: review -> review
2022-11-10 14:54:29adminsetstatus: review -> review
2022-11-10 14:54:29adminsetmessages: + msg6995
2022-11-10 14:54:29adminsetstatus: review -> review
2022-10-30 07:00:39adminsetstatus: ready -> review
2022-10-30 07:00:39adminsetstatus: ready -> ready
2022-10-30 07:00:39adminsetstatus: ready -> ready
2022-10-30 07:00:39adminsetstatus: open -> ready
2022-07-04 00:00:00admincreate