Created on 2024-05-30.00:00:00 last changed 5 months ago
Suggested resolution:
(Note that the value representation of a union arguably depends on which of its members is active.)
Change in 11.4.5.3 [class.copy.ctor] paragraph 15 as follows:
The implicitly-defined copy/move constructor for a union X copies theobjectvalue representation (6.8.1 [basic.types.general]) of X. For each object nested within (6.7.2 [intro.object]) the object that is the source of the copy, a corresponding object o nested within the destination is identified (if the object is a subobject) or created (otherwise), and the lifetime of o begins before the copy is performed.
Change in 11.4.6 [class.copy.assign] paragraph 13 as follows:
The implicitly-defined copy/move assignment operator for a union X copies theobjectvalue representation (6.8.1 [basic.types.general]) of X. If the source and destination of the assignment are not the same object, then for each object nested within (6.7.2 [intro.object]) the object that is the source of the copy, a corresponding object o nested within the destination is created, and the lifetime of o begins before the copy is performed.
(From submission #542.)
Consider:
union U {};
struct S {
U u [[no_unique_address]];
char c;
};
S s;
s.c = 1;
s.u = U(); // #1
As specified, the move-assignment at #1 might disturb the value of s.c.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-06-02 08:44:12 | admin | set | messages: + msg7724 |
2024-05-30 00:00:00 | admin | create |