On Fri, Nov 08, 2024 at 06:40:16PM +0100, Jakub Jelinek wrote:
> clang++ adds __builtin_operator_{new,delete} builtins which as documented
> work similarly to ::operator {new,delete}, except that it is an error
> if the called ::operator {new,delete} is not a replaceable global operator
> and allow optimizations which C++ normally allows just when those are used
> from new/delete expressions https://eel.is/c++draft/expr.new#14
> When using these builtins, the same optimizations can be done even when
> using those builtins.
> 
> For GCC we note that in the CALL_FROM_NEW_OR_DELETE_P flag on CALL_EXPRs.
> The following patch implements it as a C++ FE keyword (because passing
> references through ... changes the argument and so BUILT_IN_FRONTEND
> builtin can't be used), just attempts to call the ::operator {new,delete}
> and if it isn't replaceable, diagnoses it.
> 
> So far lightly tested, ok for trunk if it passes bootstrap/regtest
> (note, libstdc++ already uses the builtin)?

Bootstrapped/regtested successfully on x86_64-linux and i686-linux.

        Jakub

Reply via email to