C++ Logo


Advanced search

Wording about lifetime seems to be defective for temporaries

From: Brian Bi <bbi5291_at_[hidden]>
Date: Thu, 13 Jun 2019 13:03:21 -0500
[class.dtor]/12 says: "A destructor is invoked implicitly ... for a
constructed object with automatic storage duration (6.7.3) when the block
in which an object is created exits (9.7), ..."
This appears to imply that a parameter object should be destroyed when the
block *containing the call* is exited, since the object is created in the
calling context.

Yet the intended rule for destruction of parameter objects is in
[expr.call]/4: "... It is implementation-defined whether the lifetime of a
parameter ends when the function in which it is defined returns or at the
end of the enclosing full-expression. ..."

This seems to suggest to me that either [class.dtor]/12 should be amended
with an exception for parameter objects, or that function parameters have a
special storage duration which is not quite the same as automatic storage

Should I file a defect report for this?
*Brian Bi*

Received on 2019-06-13 13:05:22