This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/56126] -fno-exceptions should activate -fcheck-new or issue diagnostic for all new operators without throw()
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Jan 2015 13:43:37 +0000
- Subject: [Bug c++/56126] -fno-exceptions should activate -fcheck-new or issue diagnostic for all new operators without throw()
- Auto-submitted: auto-generated
- References: <bug-56126-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56126
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Why would you want an operator new that can't throw but is declared to
potentially throw? The exception specification is defined by the language to
inform the compiler whether to check the result or not, so use that.
IMHO if your operator new returns null instead of throwing then it should be
declared non-throwing (which can be done conditionally based on whether
exceptions are enabled).
If declaring it like that really isn't possible, then you should use
-fcheck-new, but it seems OK to not enable that automatically and rely on
correct exception specifications.