analyzer: fix ICE due to comparing int and real constants (PR 93547)
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 3 Feb 2020 11:34:20 +0000 (06:34 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 3 Feb 2020 19:23:27 +0000 (14:23 -0500)
gcc/analyzer/ChangeLog:
PR analyzer/93547
* constraint-manager.cc
(constraint_manager::get_or_add_equiv_class): Ensure types are
compatible before comparing constants.

gcc/testsuite/ChangeLog:
PR analyzer/93547
* gcc.dg/analyzer/pr93547.c: New test.

gcc/analyzer/ChangeLog
gcc/analyzer/constraint-manager.cc
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/analyzer/pr93547.c [new file with mode: 0644]

index 66d46b0dc8286c65eaa18809d04c42f04c6ef430..ac6fc1a30fc99b10d12bce76ce667b2eb18391d2 100644 (file)
@@ -1,3 +1,10 @@
+2020-02-03  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93547
+       * constraint-manager.cc
+       (constraint_manager::get_or_add_equiv_class): Ensure types are
+       compatible before comparing constants.
+
 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93457
index f3e31ee083071de68c8393bdac1f4d3ce792a3f4..4042c50fcb7c6a9d657c72babc0488af016ab9f7 100644 (file)
@@ -928,7 +928,9 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid)
       int i;
       equiv_class *ec;
       FOR_EACH_VEC_ELT (m_equiv_classes, i, ec)
-       if (ec->m_constant)
+       if (ec->m_constant
+           && types_compatible_p (TREE_TYPE (cst),
+                                  TREE_TYPE (ec->m_constant)))
          {
            tree eq = fold_build2 (EQ_EXPR, boolean_type_node,
                                   cst, ec->m_constant);
index cc9f3c15f85261b53f02524600e254b7dd9c46fc..94e83da480b450317614d311f661435a0cf7e82f 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-03  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93547
+       * gcc.dg/analyzer/pr93547.c: New test.
+
 2020-02-03  Stam Markianos-Wright  <stam.markianos-wright@arm.com>
 
        PR target/91816
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93547.c b/gcc/testsuite/gcc.dg/analyzer/pr93547.c
new file mode 100644 (file)
index 0000000..1518904
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+void
+wy (int);
+
+int
+f9 (void)
+{
+  int p5 = __builtin_ilogb (__builtin_inf ());
+
+  wy (0);
+
+  return p5;
+}