[Bug c++/56126] -fno-exceptions should activate -fcheck-new or issue diagnostic for all new operators without throw()
bruck.michael at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jan 8 21:20:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56126
--- Comment #11 from Michael Bruck <bruck.michael at googlemail dot com> ---
(In reply to Olaf van der Spek from comment #10)
> > I quoted it to illustrate that returning NULL is the intuitive option here,
> > while abort() is a completely new approach. Returning NULL is what I would
> > expect to be the case when -fno-exceptions is active and it is what happens in
> > the libc++ implementation AFAIK.
>
> -fno-exceptions transforms throws into aborts in the STL.
> Unfortunately it doesn't do that for other code but I've filed a
> feature request for to fix that.
>
> Given this transformation aborting would be the natural consequence.
> What does the GCC STL do?
throwing is undefined behavior with -fno-exceptions. Allocation failure is a
simple error and should not kill your program.
> BTW, what's your use case? Do you really want to check NULL on every
> call to new?
With -fno-exceptions you have to check all functions for errors, including
allocation.
More information about the Gcc-bugs
mailing list