http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58159
Bug ID: 58159 Summary: unique_ptr::reset should have debug assertion for "self-reset" Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gromer at google dot com unique_ptr::reset() should have a debug assertion for the case that the input pointer is not null, and is equal to the pointer already stored. This is virtually always an error: it violates the basic ownership logic of unique_ptr, and leaves unique_ptr holding a dangling pointer. Strictly speaking, this is not undefined behavior in itself, but almost any subsequent operation other than release() (even destroying the unique_ptr) will produce undefined behavior, so this seems like a highly defensible condition to assert on, at least in debug mode. This kind of error is rare, but it does happen; see e.g. https://code.google.com/p/chromium/issues/detail?id=162971.