This is the mail archive of the 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 COMMITTED: Fix bug building complex C++ code

This patch fixes an ICE reported by Tom Tromey on some complicated C++
test case.  I don't have a test case.  Tom tested the patch and
confirmed that it fixed the problem he saw.

The problem was that an value with TREE_OVERFLOW set appeared in a
conditional, and it led VRP to think it was an overflow infinity
indication.  This then triggered an ENABLE_CHECKING check.  Fixed by
using the same value without TREE_OVERFLOW set.

Tested with bootstrap and testsuite on i686-pc-linux-gnu.  Committed
to mainline.

This patch is latent on 4.2 branch, so I committed it there after
testing as well.


2007-05-22  Ian Lance Taylor  <>

	* tree-vrp.c (avoid_overflow_infinity): New static function,
	broken out of set_value_range_to_value.
	(set_value_range_to_value): Call avoid_overflow_infinity.
	(extract_range_from_assert): Likewise.

Index: tree-vrp.c
--- tree-vrp.c	(revision 124930)
+++ tree-vrp.c	(working copy)
@@ -201,6 +201,27 @@ is_overflow_infinity (tree val)
 	      || operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0)));
+/* If VAL is now an overflow infinity, return VAL.  Otherwise, return
+   the same value with TREE_OVERFLOW clear.  This can be used to avoid
+   confusing a regular value with an overflow value.  */
+static inline tree
+avoid_overflow_infinity (tree val)
+  if (!is_overflow_infinity (val))
+    return val;
+  if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0))
+    return TYPE_MAX_VALUE (TREE_TYPE (val));
+  else
+    {
+      gcc_assert (operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0));
+      return TYPE_MIN_VALUE (TREE_TYPE (val));
+    }
 /* Return whether VAL is equal to the maximum value of its type.  This
    will be true for a positive overflow infinity.  We can't do a
@@ -361,19 +382,7 @@ static inline void
 set_value_range_to_value (value_range_t *vr, tree val, bitmap equiv)
   gcc_assert (is_gimple_min_invariant (val));
-  if (is_overflow_infinity (val))
-    {
-      if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0))
-	val = TYPE_MAX_VALUE (TREE_TYPE (val));
-      else
-	{
-	  gcc_assert (operand_equal_p (val,
-				       TYPE_MIN_VALUE (TREE_TYPE (val)), 0));
-	  val = TYPE_MIN_VALUE (TREE_TYPE (val));
-	}
-    }
+  val = avoid_overflow_infinity (val);
   set_value_range (vr, VR_RANGE, val, val, equiv);
@@ -1103,6 +1112,8 @@ extract_range_from_assert (value_range_t
       cond_code = swap_tree_comparison (TREE_CODE (cond));
+  limit = avoid_overflow_infinity (limit);
   type = TREE_TYPE (limit);
   gcc_assert (limit != var);

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