[Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.

redi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Mar 1 22:31:00 GMT 2010



------- Comment #11 from redi at gcc dot gnu dot org  2010-03-01 22:30 -------
(In reply to comment #10)
> I think it should still check for resetting to the same value to avoid 
> duplicate deletes later.

I disagree, double delete can only happen in the case of a programming error.

Look at my second example in comment #5 - it may not be a very good idea to
write code like that, but it is technically correct (the stored pointer is
deleted when reset() is called, then released so it won't be deleted again) and
should not leak the stored pointer. If you check for the same value then you
will not call the deleter during reset and will leak.

I am testing a fix now, but I will not include your suggestion to check p!=old,
the C++0x draft requires a certain behaviour and I will implement that.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43183



More information about the Gcc-bugs mailing list