[basic.life] Lifetime of union member CWG2675 #3222
Labels
cwg
Issue must be reviewed by CWG.
not-editorial
Issue is not deemed editorial; the editorial issue is kept open for tracking.
In the latest draft of the C++ standard, [basic.life]/1 states:
From that paragraph I understand that the only way a member of a union begins its lifetime is:
However, the only normative paragraph in [class.union] that specifies how a union member can begin its lifetime is [class.union]/5 (but it only applies to specific types, i.e. either non-class, non-array, or class type with a trivial constructor that is not deleted, or array of such types).
The next paragraph, [class.union]/6 (comprising a note and an example, therefore it contains no normative text), describes a way to change the active member of a union, by using a placement new-expression, such as
new (&u.n) N
. However, based on [basic.life]/1, the lifetime ofu.n
should not start when using the placement new-expression.If I am not missing anything, I believe that either [basic.life]/1 should be changed or a new paragraph must be added to [class.union].
The text was updated successfully, but these errors were encountered: