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

[except.spec]/5 suggests that destructors are only considered for full-expressions #7473

Closed
zygoloid opened this issue Dec 4, 2024 · 0 comments · Fixed by #7477
Closed
Assignees

Comments

@zygoloid
Copy link
Member

zygoloid commented Dec 4, 2024

[except.spec]/5:

An expression E is potentially-throwing if [...] E implicitly invokes a function (such as an overloaded operator, an allocation function in a new-expression, a constructor for a function argument, or a destructor if E is a full-expression) that has a potentially-throwing exception specification [...]

While this is just a list of examples, it can be read as suggesting that the exception specification of a destructor only contributes to whether an expression is potentially-throwing if the expression is a full-expression. But that's not correct -- the expression delete p should consider the destructor of the type of *p (assuming it's a class type and doesn't have a destroying operator delete) regardless of whether it's a full-expression. Also, per [expr.call]/6, parameters in a function call may be destroyed when the call returns rather than at the end of the full-expression.

Also... do we ever even query whether a non-full expression is potentially-throwing? (The definition of potentially-throwing recurses to subexpressions.) The operand of noexcept is a full-expression, and I'd hope we take destructors of temporaries into account in all the other places we use the term!

Suggestion: delete the "if E is a full-expression".

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