Calling these C++ built-in functions is similar to calling
::operator new
or ::operator delete
with the same arguments,
except that it is an error if the selected ::operator new
or
::operator delete
overload is not a replaceable global operator
and for optimization purposes calls to pairs of these functions can be
omitted if access to the allocation is optimized out, or could be replaced
with implementation provided buffer on the stack, or multiple allocation
calls can be merged into a single allocation. In C++ such optimizations
are normally allowed just for calls to such replaceable global operators
from new
and delete
expressions.
void foo () { int *a = new int; delete a; // This pair of allocation/deallocation operators can be omitted // or replaced with int _temp; int *a = &_temp; etc. void *b = ::operator new (32); ::operator delete (b); // This one cannnot. void *c = __builtin_operator_new (32); __builtin_operator_delete (c); // This one can. }