Hi, I noticed what seems to be an issue when implementing a custom deleter to be used with a unique_ptr.
In most cases (e.g. here), the pointer is checked and is not passed to the deleter if it's nullptr. However, that check is missing here in reset(). So, if you assign a valid unique_ptr to an empty unique_ptr, the deleter is called on a null pointer.
Or, is this intended behavior, and the deleter is simply supposed to ignore null pointers when called on them? If that's the case then this isn't a bug, though maybe the behavior should be made clearer in the docs.
Hi, I noticed what seems to be an issue when implementing a custom deleter to be used with a unique_ptr.
In most cases (e.g. here), the pointer is checked and is not passed to the deleter if it's nullptr. However, that check is missing here in
reset()
. So, if you assign a valid unique_ptr to an empty unique_ptr, the deleter is called on a null pointer.Or, is this intended behavior, and the deleter is simply supposed to ignore null pointers when called on them? If that's the case then this isn't a bug, though maybe the behavior should be made clearer in the docs.