This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Bug in gcc-2.95 prerelease
- To: coryan at cs dot wustl dot edu, egcs-bugs at egcs dot cygnus dot com
- Subject: Re: Bug in gcc-2.95 prerelease
- From: mrs at wrs dot com (Mike Stump)
- Date: Thu, 15 Jul 1999 14:34:04 -0700
> From: "Carlos O'Ryan" <coryan@cs.wustl.edu>
> Date: Thu, 15 Jul 1999 14:13:50 -0500 (CDT)
> See my point above: issuing a diagnostic for a situation that
> cannot be fixed is (IMHO) a bug;
-fcheck-new should cause the warning/error to go away. If it doesn't
than that _is_ a bug.
> the test for "new must throw" should be disabled if exceptions are
> disabled.
No, what should be changed is the wording of the message. This is a
minor nit. If -fcheck-new is in effect, we can remove it.
> Sure, i only have to change 1,000,000 lines of code to do that
If you lucky, you can
#define new new(nothrow)
in your .h file, this is a small change.
> > If you insist on doing what you want, you will need -fcheck-new,
> Hmmm, from the flag documentation it would seem like this will
> fix the run-time behavior; i'm not complaining about the resulting
> run-time behavior;
That's unfortunate. It means you haven't tested the code any (when
you return 0). It should be near useless without it.
> My only complaint is that *if* exceptions are disabled (have
> no problems with it if exceptions are enabled), this particular
> diagnostic is at least misleading and i would even say that it is
> plain wrong. In fact the problem is fairly easy to fix, and here is
> the patch:
> ---------------- cut here ----------------
> --- typeck.c.orig Thu Jul 15 13:50:39 1999
> +++ typeck.c Thu Jul 15 13:51:42 1999
> @@ -7352,7 +7352,8 @@
> if ((DECL_NAME (current_function_decl) == ansi_opname[(int) NEW_EXPR]
> || DECL_NAME (current_function_decl) == ansi_opname[(int) VEC_NEW_EXPR])
> && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
> - && null_ptr_cst_p (retval))
> + && null_ptr_cst_p (retval)
> + && doing_eh (0))
> cp_pedwarn ("operator new should throw an exception, not return NULL");
>
> if (retval == NULL_TREE)