From ea789238b2c24eedf70b56257235adf3d33c5a0a Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Mon, 19 Jul 2021 15:16:25 -0400
Subject: [PATCH 2/3] Check for undefined on COND_EXPR before querying type.
gcc/
PR tree-optimization/101497
* gimple-range-fold.cc (fold_using_range::range_of_cond_expr): Check
for undefined.
gcc/testsuite
* gcc.dg/pr101497.c: New.
---
gcc/gimple-range-fold.cc | 3 ++-
gcc/testsuite/gcc.dg/pr101497.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr101497.c
@@ -1111,7 +1111,8 @@ fold_using_range::range_of_cond_expr (irange &r, gassign *s, fur_source &src)
r = range1;
r.union_ (range2);
}
- gcc_checking_assert (range_compatible_p (r.type (), type));
+ gcc_checking_assert (r.undefined_p ()
+ || range_compatible_p (r.type (), type));
return true;
}
new file mode 100644
@@ -0,0 +1,13 @@
+/* PR tree-optimization/101497 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-div-by-zero" } */
+
+char uc_1;
+int i_4, func_12_uli_6;
+void func_12() {
+ int *ptr_8 = &func_12_uli_6;
+ *ptr_8 = 0 >= 211 - uc_1 <= 0;
+ i_4 %= 0;
+ i_4 *= *ptr_8;
+}
+
--
2.17.2