On 08/01/2018 05:25 AM, Marc Glisse wrote:
Throwing new is returns_nonnull (errors are reported with exceptions) so
that's fine, but non-throwing new is not:
int* p1 = new(std::nothrow) int;
Here errors are reported by returning 0, so it is common to test if p1
is 0 and this is precisely the case that could benefit from a predictor
but does not have the attribute to do so (there are also consequences on
aliasing).
Agreed. both throwing and non-throwing operator new are malloc-like.
Placement new doesn't throw, it is explicitly defined to return the
passed in pointer (and it's not replaceable by the user). So may return
null, but I don't think any code (outside of a conformance testsuite)
would actually do that.
I can't find words that specify the return value of any allocation
function is unaliased to any existing object. The closest it gets is
that the non-placement forms might be implemented via malloc and friends.
nathan
--
Nathan Sidwell