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
[intro.execution] CWG2431: Destruction of a temp. object bound to a reference is not a full-expression? #2664
Comments
If you have multiple lifetime-extended temporaries, do their destructors produce multiple full-expressions?
The current wording seems to allow the destructor invocations |
If I have multiple non-reference variables, do their destruction produce multiple full-expressions? |
Yes, but the destruction of temporary objects doesn't have to produce multiple full-expressions, so there's no inherent requirement that destruction of objects happens in separate full-expressions. |
Ok, the difference could be intended, lets wait what others will say. |
The text is clearly wrong (a lifetime-extended temporaries should be treated as-if it were a non-reference variable), but is the fix editorial? |
Given the ambiguity Jonathan mentioned, I think we should process this as a core issue. |
@jensmaurer the difference would be observable if a destructor throws an exception. |
@languagelawyer, sorry, maybe it's too early in the morning for me, but could you please be more specific? |
@jensmaurer if there are several temporary object destructor invocations in one full-expression and one of them throws an exception, it will finish evaluating the rest of the full-expression and could left some destructors not invoced. But if each destructor invocation is a full-expression and one of them thows, the following destructors still would be called during stack unwinding. |
@languagelawyer: Such behavior would be at odds with [stmt.jump] p2: Even if a destructor throws an exception, you still need to execute the rest of the destructors, now in the context of stack unwinding [except.ctor]. |
@jensmaurer hm, indeed. Then I also don't see a difference. |
I'm not aware of any way the difference is observable, so maybe it can be changed editorially (or maybe it doesn't need to change at all). My original comment was just to say that "it is intended to be a full-expression" may need additional justification, as it's not obvious to me whether that really is the intention. |
http://eel.is/c++draft/intro.execution#def:full-expression:
Here is an example
I think it is intended to be a full-expression, so the Standard should say something like
The text was updated successfully, but these errors were encountered: