This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR27488: ICE in tree_expr_nonnegative_p, at fold-const.c:11774
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 11 May 2006 09:09:45 +0200 (CEST)
- Subject: [patch] Fix PR27488: ICE in tree_expr_nonnegative_p, at fold-const.c:11774
Currently the compiler ICEs on invalid code like:
void foo()
{
fabs(sinh(0..));
}
bug.cc:3:13: error: too many decimal points in number
bug.cc:3: internal compiler error: tree check: expected class 'type',
have 'exceptional' (error_mark) in tree_expr_nonnegative_p,
at fold-const.c:11774
Please submit a full bug report, [etc.]
The patch below fixes the ICE by adding a sanity check for the argument
of tree_expr_nonnegative_p.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline and 4.1 branch?
Regards,
Volker
:ADDPATCH middle-end:
2006-05-11 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR middle-end/27488
* fold-const.c (tree_expr_nonnegative_p): Return early on invalid
expression.
===================================================================
--- gcc/gcc/fold-const.c (revision 113669)
+++ gcc/gcc/fold-const.c (working copy)
@@ -11773,6 +11773,9 @@ tree_expr_nonnegative_p (tree t)
int
tree_expr_nonnegative_p (tree t)
{
+ if (t == error_mark_node)
+ return 0;
+
if (TYPE_UNSIGNED (TREE_TYPE (t)))
return 1;
===================================================================
2006-05-11 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR middle-end/27488
* gcc.dg/fold-nonneg-1.c: New test.
===================================================================
--- gcc/gcc/testsuite/gcc.dg/fold-nonneg-1.c 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/gcc.dg/fold-nonneg-1.c 2006-05-10 10:09:14 +0200
@@ -0,0 +1,10 @@
+/* PR middle-end/27488 */
+/* { dg-do compile } */
+
+extern double fabs(double x);
+extern double sinh(double x);
+
+void foo()
+{
+ fabs(sinh(0..)); /* { dg-error "decimal points" } */
+}
===================================================================