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

[class.init] Replace abominable temporary expression wording #4235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

languagelawyer
Copy link
Contributor

@languagelawyer languagelawyer commented Sep 25, 2020

Finally fixes #1910

Comment on lines -5785 to 5787
A temporary expression bound to a reference member in a \grammarterm{mem-initializer}
A program extending the lifetime of a temporary object
by binding it to a reference member in a \grammarterm{mem-initializer}
is ill-formed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we phrase this as a regular "shall not" rule, rather than "A program ... is ill-formed"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like: "A program shall not (attempt to?) extend the lifetime of a temporary object by binding it to a reference member ..."?

@zygoloid
Copy link
Member

I think it would be better to move this wording into the second set of bullets in [class.temporary]p6. I'm not sure why we moved it out of there to here.

@languagelawyer
Copy link
Contributor Author

I think it would be better to move this wording into the second set of bullets in [class.temporary]p6. I'm not sure why we moved it out of there to here.

But the second set of bullets is about when the lifetime extension/shrink doesn't happen and the program is still well-formed. Whilst here the program is ill-formed.

@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 14, 2020

@zygoloid: any further thoughts on this? Should we take this to CWG?

@zygoloid
Copy link
Member

I still think moving to [class.temporary]p6, so we have all the rules for lifetime-extension in the same place, would make more sense. The status quo is that we say that lifetime is extended in these cases, and then rules elsewhere say that if that happens, the program's ill-formed, which seems both a little too indirect and confusing (until we find it's ill-formed, we need to keep in our minds the idea of a program that performs a lifetime extension that can't possibly work in practice).

If we keep it where it is, I still think a "shall not" phrasing would be preferable.

If we can't reach consensus, asking CWG for input might help, but I think this is fundamentally editorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes to the wording or approach have been requested and not yet applied.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[expr.comma, class.base.init] What is "temporary expression"?
3 participants