Closed frederick-vs-ja closed 1 month ago
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 T x {};
assuming this is value-initialization: because value-initialization performs default-initialization, one could say that x
is default-initialized.
Ok.
CWG2860
Perhaps should be closed, as CWG2860 is treated as duplicate of CWG2859 which is resolved.
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: