[Bug c++/85783] alloc-size-larger-than fires incorrectly with new[] and can't be disabled

psmith at gnu dot org gcc-bugzilla@gcc.gnu.org
Tue May 15 17:02:00 GMT 2018


--- Comment #7 from Paul Smith <psmith at gnu dot org> ---
Is there a way (in standard C++) to force non-inline?  I'm not aware of one. 
So that means the only standard-conforming way to replace operator new is if
it's in its own compilation unit all by itself?  I don't have a copy of the
standard but cppreference says only that replacement operator new can't have an
inline specifier, that it can't be static, and that it has to be in the global
namespace, all of which requirements this example appears to meet.

Regarding throw, does the standard really say that the throw must be explicit
in the implementation of the function directly?  If my operator new[] invokes a
function to throw, rather than throwing directly, is that not
standard-conforming?  That seems bizarre to me: just because the compiler can't
prove to itself that my operator new will throw properly, the compiler is
allowed to assume the code is non-conforming?

More information about the Gcc-bugs mailing list