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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Matthijs Kooijman from comment #6)
> Ah, IIUC your patch does not treat -fno-exceptions specially, but just adds
> a shortcut for the nothrow new version to skip calling regular new version
> if it has not been replaced. In a normal build, that saves throw/catch
> overhead, and in a no-exceptions build that prevents the abort associated
> with that throw. Clever!

Right.


> One corner case seems to be when the regular new version is replaced in a
> no-exceptions build, but in that case that replacement has no way to signal
> failure anyway, and if needed a user can just also replace the nothrow
> version.

If the regular version has been replaced, we have to call it (and handle
possible exceptions) because we can't know what it does, so calling malloc
directly would not be safe. So yes, users who want to replace new but don't
want exceptions involved in the nothrow new path just need to replace both
forms. That's true already today, and my patch wouldn't change it.

Reply via email to