This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] cse.c: gcc_assertify an "if" statement whose conditionis always false.


Jakub Jelinek wrote:
On Wed, Jan 26, 2005 at 03:21:30PM -0500, Kazu Hirata wrote:

2005-01-26 Kazu Hirata <kazu@cs.umass.edu>

	* cse.c (fold_rtx): gcc_assertify an "if" statement whose
	condition is always false.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.332
diff -c -d -p -r1.332 cse.c
*** cse.c 26 Jan 2005 12:44:58 -0000 1.332
--- cse.c 26 Jan 2005 12:49:24 -0000
*************** fold_rtx (rtx x, rtx insn)
*** 3239,3246 ****
extends. */
enum machine_mode mode_arg0;
! if (x == 0)
! return x;
mode = GET_MODE (x);
code = GET_CODE (x);
--- 3239,3247 ----
extends. */
enum machine_mode mode_arg0;
! #ifdef ENABLE_CHECKING
! gcc_assert (x != NULL_RTX);
! #endif
mode = GET_MODE (x);
code = GET_CODE (x);


If x is never NULL, I think deleting it is equally good.
If x is NULL, you'll segfault on GET_MODE (x), which is as good as
assertion failure.

I dunno, I like asserts -- they document the assumption. But, there's no point in guarding ggc_assert with ENABLE_CHECKING, as ggc_assert already is conditionalized on that macro. OK with that change.


--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]