gcc/analyzer/ChangeLog:
PR analyzer/124433
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): When checking for
division by zero, use the value range of the divisor, rather
than merely checking for constant 0.
* region-model.cc (region_model::get_gassign_result): Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/124433
* gcc.dg/analyzer/divide-by-zero-ice-pr124433.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
case ROUND_MOD_EXPR:
case RDIV_EXPR:
case EXACT_DIV_EXPR:
- if (cst1 && zerop (cst1))
- return get_or_create_unknown_svalue (type);
+ {
+ value_range arg1_vr;
+ if (arg1->maybe_get_value_range (arg1_vr))
+ if (arg1_vr.zero_p ())
+ return get_or_create_unknown_svalue (type);
+ }
break;
}
|| op == RDIV_EXPR
|| op == EXACT_DIV_EXPR))
{
- if (const tree rhs2_cst = rhs2_sval->maybe_get_constant ())
- if (zerop (rhs2_cst))
+ value_range rhs_vr;
+ if (rhs2_sval->maybe_get_value_range (rhs_vr))
+ if (rhs_vr.zero_p ())
{
/* Ideally we should issue a warning here;
see PR analyzer/124217. */
--- /dev/null
+unsigned m;
+int c;
+
+void
+foo()
+{
+ do c %= (5ull << 40) & m;
+ while (c);
+}