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.temporary] Clarify wording for lifetime of temporaries. #6562

Open
leni536 opened this issue Sep 11, 2023 · 2 comments
Open

[class.temporary] Clarify wording for lifetime of temporaries. #6562

leni536 opened this issue Sep 11, 2023 · 2 comments

Comments

@leni536
Copy link

leni536 commented Sep 11, 2023

Current wording

draft/source/basic.tex

Lines 4379 to 4383 in 16c8ce5

Temporary objects are destroyed as the last step
in evaluating
the full-expression\iref{intro.execution}
that (lexically) contains the point where
they were created.

As far as I know "(lexically) contained" is not defined.

The presence of "lexically" here is especially confusing in the light of this note:

draft/source/basic.tex

Lines 5824 to 5831 in 16c8ce5

\begin{note}
The evaluation of a full-expression can include the
evaluation of subexpressions that are not lexically part of the
full-expression. For example, subexpressions involved in evaluating
default arguments\iref{dcl.fct.default} are considered to
be created in the expression that calls the function, not the expression
that defines the default argument.
\end{note}

Intent

I think the intent is pretty clear in light of the subexpression wording and corresponding examples that the lifetime of a temporary should be solely be determined by the corresponding full-expression of the temporary materialization conversion subexpression that initialized it. Any "lexical" relationship is incidental.

Suggested wording

I think the [class.temporary] wording can be expressed purely with subexpressions, like so:

At the end of a full-expression temporaries that are initialized by temporary materialization conversion [conv.rval] subexpressions are destroyed.

@frederick-vs-ja
Copy link
Contributor

It seems that we should cover both subexpressions and constituent expressions.

Is it clear enough to say the following?

Temporary objects are destroyed as the last step in evaluating the full-expression ([intro.execution]) that (lexically) contains the point where they were created of the temporary materialization conversions ([conv.rval]) that initialized the temporary objects.

@leni536
Copy link
Author

leni536 commented Sep 16, 2023

It seems that we should cover both subexpressions and constituent expressions.

You are probably right

Is it clear enough to say the following?

Temporary objects are destroyed as the last step in evaluating the full-expression ([intro.execution]) that (lexically) contains the point where they were created of the temporary materialization conversions ([conv.rval]) that initialized the temporary objects.

What's a "full-expression of "? I guess it's meant to be the inverse relationship of "subexpression or constituent expression of ", but I don't think it's defined anywhere. I think your proposed wording would be clear if "full-expression of" also gets defined elsewhere.

Alternatively the following wording could be used.

As the last step in evaluating a full-expression the temporaries that are initialized [conv.rval] in subexpressions or constituent expressions of the full-expression are destroyed.

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

No branches or pull requests

2 participants