[Bug libstdc++/86954] redundant nothrow in call of ::operator delete

2018-08-14 Thread frankhb1989 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86954

--- Comment #4 from frankhb1989 at gmail dot com ---
Well, actually I'm not sure if the original implementation has done the right
thing, as I don't find that the standard has requirement to specify that the
replaced definitions must acknowledge the fact nothrow_t overloads should only
be called on the specified condition (... and if so, whether it worth an LWG
issue).

But that still seems suspicious to me, because symmetry of call between
nothrow_t placement ::operator new and ::operator delete does not exist in the
language indeed, so that seems like an unintentional use unless it is
documented elsewhere. On the other hand, the change here towards to a simpler
and undoubtedly conformant way.

BTW, I do know the feature is deprecated in C++17 and removed in C++2a. I read
the paper of deprecation. It is plausible to be removed from the standard, but
not a must - not with a very strong reason. However, I am sure I do need that
feature so I have to reinvent my wheels... as done internally by various
standard library implementations. (More specifically, I need
std::_Temporary_buffer in libstdc++ and MSVC's current 
implementation, or at least something equivalent to
std::__return_temporary_buffer in libc++, but surely I can't rely on them
directly.) At least a raw call of allocation function does not always express
the intended call site requirements clearly like std::get_temporary_buffer, so
users who want to make it clear have to afford the extra layer of an
abstraction. Arguably, the removal will bloat work for anyone wants that and
discourage clearer expression of intentions.

[Bug libstdc++/86954] redundant nothrow in call of ::operator delete

2018-08-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86954

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |9.0

--- Comment #3 from Jonathan Wakely  ---
On the other hand, with PR 68210 fixed the change is harmless. So fixed on
trunk.

Not suitable for backports though.

[Bug libstdc++/86954] redundant nothrow in call of ::operator delete

2018-08-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86954

--- Comment #2 from Jonathan Wakely  ---
Author: redi
Date: Tue Aug 14 20:19:20 2018
New Revision: 263542

URL: https://gcc.gnu.org/viewcvs?rev=263542&root=gcc&view=rev
Log:
PR libstdc++/86954 use non-placement operator delete

As explained in the PR, there's no reason to call the nothrow delete,
we can just use the normal one.

PR libstdc++/86954
* include/bits/stl_tempbuf.h (return_temporary_buffer): Use
non-placement delete.

Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/stl_tempbuf.h

[Bug libstdc++/86954] redundant nothrow in call of ::operator delete

2018-08-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86954

--- Comment #1 from Jonathan Wakely  ---
Arguably this was good defensive programming for C++03. The program could have
replaced operator new(size_t) and operator delete(void*) but not replaced
operator new(size_t, const nothrow_t&) and operator delete(void*, const
nothrow_t&). That would be undefined (C++03 [lib.new.delete.single] p7) but by
using the nothrow version of operator delete the library avoids mixing the
default version of new with a replaced version of delete. LWG 206 changed the
behaviour for C++11, so that combining the nothrow new and normal delete does
the right thing, but GCC has only met that requirement since yesterday.

I'm not sure it's worth changing anything here now. get_temporary_buffer was
deprecated and removed from C++2a anyway.