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

[basic.life] p1 omits a cross-reference to [class.copy.assign] for union member case #5219

Closed
xmh0511 opened this issue Jan 21, 2022 · 0 comments · Fixed by #5228
Closed
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jan 21, 2022

The lifetime of an object of type T begins when:

  • [...]

except that if the object is a union member or subobject thereof, its lifetime only begins if that union member is the initialized member in the union ([dcl.init.aggr], [class.base.init]), or as described in [class.union] and [class.copy.ctor], and except as described in [allocator.members].

[class.copy.assign] p13 explicitly states

If the source and destination of the assignment are not the same object, then for each object nested within ([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.

So, [basic.life] p1 should be: or as described in [class.union], [class.copy.ctor], and [class.copy.assign].


Incidentally, I think [basic.life] should cover the complete story regards of when/how the lifetime of an object will be begun, as its subject is regarding lifetime. For instance, these operations are phrased as implicitly creating objects, which can also start the lifetimes for objects.

@xmh0511 xmh0511 changed the title [basic.life] p1 omite a cross-reference to [class.copy.assign] for union member case [basic.life] p1 omites a cross-reference to [class.copy.assign] for union member case Jan 21, 2022
@jensmaurer jensmaurer self-assigned this Jan 21, 2022
@jensmaurer jensmaurer changed the title [basic.life] p1 omites a cross-reference to [class.copy.assign] for union member case [basic.life] p1 omits a cross-reference to [class.copy.assign] for union member case Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants