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.
This commit is contained in:
Andrew MacLeod 2021-07-19 15:16:25 -04:00
parent e58093276a
commit ea789238b2
2 changed files with 15 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;
}