This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Mar 2010 22:30:57 -0000
- Subject: [Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.
- References: <bug-43183-18834@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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