This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/58159] unique_ptr::reset should have debug assertion for "self-reset"


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58159

--- Comment #6 from Geoff Romer <gromer at google dot com> ---
A Chromium maintainer privately pointed out a use case that would be thwarted
by a check like this: basically, unique_ptr is used to hold pointers from a
legacy API, using a custom deleter that decrements a reference count rather
than actually destroying the object. If the legacy API returns the same pointer
from multiple calls, this can lead to reset() being legitimately called with a
pointer equal to the stored value.

So on reflection, I agree this can only be done for default_delete.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]