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]

[PATCH] Fix ICE in fold-const.c


I do not have a testcase for this patch as it cannot happen in C or
C++ or Java as you convert the (bool)(a) into a != 0.

The ICE can happens when !(bool)a is passed to fold because fold will
use STRIP_SIGNED_NOPS which removes the cast to bool which causes an
ICE in invert_truthvalue.

Bootstrapped on powerpc-apple-darwin7.3.0 with no regressions.
OK?

Thanks,
Andrew Pinski

ChangeLog:

	* fold-const.c (fold) [case TRUTH_NOT_EXPR]: Make sure the type is
	of BOOLEAN_TYPE.



Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.376
diff -u -p -r1.376 fold-const.c
--- fold-const.c	15 May 2004 23:07:49 -0000	1.376
+++ fold-const.c	16 May 2004 22:42:16 -0000
@@ -7192,6 +7202,9 @@ fold (tree expr)
       goto associate;

     case TRUTH_NOT_EXPR:
+      if (TREE_CODE (arg0) != BOOLEAN_TYPE)
+          arg0 = fold (TREE_OPERAND (t, 0));
+
       /* Note that the operand of this must be an int
 	 and its values must be 0 or 1.
 	 ("true" is a fixed value perhaps depending on the language,


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