[Bug tree-optimization/26388] Variable sized storage allocation should be promoted to stack allocation

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 17 20:52:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26388

--- Comment #17 from Martin Sebor <msebor at gcc dot gnu.org> ---
The quoted text allows an implementation to to merge calls made by two or more
new expressions to the underlying allocation function (operator new).  It can
call it just once but it's can't avoid calling it altogether.

There is no such a permission for calls to the allocation function itself.

std::allocator doesn't use a new expression.  It's specified to call the
::operator new(size_t), so the permission in new.expr doesn't apply to it.  It
isn't specified when or how often the allocator calls the function so, as
Jonathan noted, for some programs it could call it just once and cache it.  But
it does have to call it and can't just get the memory from somewhere else.


More information about the Gcc-bugs mailing list