-
Notifications
You must be signed in to change notification settings - Fork 7
CWG2860 [basic.life] Remove out-of-sync term "vacuous initialization" #505
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
Comments
I think it needs to say something like "unless all such variables are default-initialized and no initialization is performed for any such variable other than calling a trivial default constructor" to exclude zero-initialization either in the context of value-initialization or static initialization. |
Oh, never mind what I said about static initialization - the rule applies only to automatic storage duration in the first place. |
What's wrong with zero-initialization? With the arrival of erroneous values, we will (in general) have some initialization of the bytes regardless, so we might as well accept zero-initialization. |
There needs to be some way of saying that we can't jump over something like |
Ok. |
Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [basic.life], [stmt.dcl]
Link to reflector thread (if any):
Issue description:
The current definition of term "vacuous initialization" was established by CWG2256, which predated P0848R3. As of C++20/P0848R3, a class may have a trivial but not eligible default constructor, while default-initialization for a variable of such a class can still call a non-trivial default constructor. Presumably we don't want to say such a variable has vacuous initialization.
E.g. the following example should be ill-formed and implementations seem to agree:
On the other hand, as of CWG2256, the term "vacuous initialization" is only essentially used in [stmt.dcl] and doesn't need to be mentioned in [basic.life]. It seems that we can dissolve the term into [stmt.dcl].
Suggested resolution:
Modify [basic.life] as indicated:
Modify [stmt.dcl] as indicated:
The text was updated successfully, but these errors were encountered: