https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58159
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- Peter Dimov pointed out an even simpler example of valid-but-questionable code: std::unique_ptr<int> p(new int); p.reset(p.get()); (void) p.release(); The pointer is invalidated by the self-reset, but then is released and so the invalid pointer is never used. He also noted that we can add a self-reset check to std::shared_ptr, because its constructor (and therefore also reset) has a precondition that 'delete p' is well-formed. There's no such precondition for std::unique_ptr.