Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[class.default.ctor] Implicit definitions of special functions #3234

Open
RazvanAM opened this issue Sep 21, 2019 · 1 comment
Open

[class.default.ctor] Implicit definitions of special functions #3234

RazvanAM opened this issue Sep 21, 2019 · 1 comment
Assignees
Labels
cwg Issue must be reviewed by CWG.

Comments

@RazvanAM
Copy link

In the current version of the C++ draft,, paragraph [class.default.ctor]/4 states:

A default constructor that is defaulted and not defined as deleted is implicitly defined when it is odr-used ([basic.def.odr]) to create an object of its class type ([intro.object]), when it is needed for constant evaluation ([expr.const]), or when it is explicitly defaulted after its first declaration. [...]. Before the defaulted default constructor for a class is implicitly defined, all the non-user-provided default constructors for its base classes and its non-static data members shall have been implicitly defined. [...]"

Sentences similar to the one highlighted in the quoted paragraph are present in the sections describing special functions ([class.default.ctor]/4, [class.copy.ctor]/13, [class.copy.assign]/11 and [class.dtor]/11).

What is the exact meaning and the purpose of this sentence?

If this sentence is a restriction on the implementation, then it could be interpreted as:

"If a defaulted default constructor for a class has to be implicitly defined, the implementation also has to implicitly define all the non-user-provided default constructors for its base classes and its non-static data members before the definition of the defaulted default constructor".

Therefore the first sentence in [class.default.ctor]/4 specifies only some contexts where the implementation has to implicitly-define a defaulted default constructor, and then this sentence specifies another such context. Is this the correct interpretation? If so, why is this sentence needed? If this sentence was missing, then the moment a defaulted default constructor is implicitly defined, the default constructors for its base classes and its non-static data members are odr-used (a use inside an implicit definition is still considered an odr-use, correct?), therefore, due to the first sentence of [class.default.ctor]/4, they would be implicitly-defined as well.

However, the wording "shall have been defined" may seem to mean that if a context triggers the generation of an implicit definition of a defaulted default constructor for class A, the implicit definitions of all the non-user-provided default constructors for A's base classes and its non-static data members should have been already generated (due to some other reason, not because of the generation of the implicit definition of A's defaulted default constructor).

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Sep 24, 2019
@jensmaurer jensmaurer changed the title Implicit definitions of special functions [class.default.ctor] Implicit definitions of special functions Sep 24, 2019
@jensmaurer
Copy link
Member

Editorial teleconference: "shall have been" -> "are" is editorial, the rest is CWG. (CWG hat: The sentence should be a note at most.)

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Sep 30, 2019
@jensmaurer jensmaurer self-assigned this Oct 4, 2019
@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

2 participants