This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 545. When is a deleter deleted?

Section: 20.11.3.11 [util.smartptr.getdeleter], 99 [tr.util.smartptr.shared.dest] Status: CD1 Submitter: Matt Austern Opened: 2006-01-10 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [util.smartptr.getdeleter].

View all issues with CD1 status.

Discussion:

The description of ~shared_ptr doesn't say when the shared_ptr's deleter, if any, is destroyed. In principle there are two possibilities: it is destroyed unconditionally whenever ~shared_ptr is executed (which, from an implementation standpoint, means that the deleter is copied whenever the shared_ptr is copied), or it is destroyed immediately after the owned pointer is destroyed (which, from an implementation standpoint, means that the deleter object is shared between instances). We should say which it is.

Proposed resolution:

Add after the first sentence of 20.11.3.11 [util.smartptr.getdeleter]/1:

> The returned pointer remains valid as long as there exists a `shared_ptr` instance that owns `d`.

> [Note: it is unspecified whether the pointer remains valid longer than that. This can happen if the implementation doesn't destroy the deleter until all `weak_ptr` instances in the ownership group are destroyed. -- end note]