Skip to content

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

Closed
@zygoloid

Description

@zygoloid

[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".

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions