if (m_cm_b->eval_condition (lhs, code, rhs).is_true ())
{
bool sat = m_out->add_constraint (lhs, code, rhs);
- gcc_assert (sat);
+ if (!sat)
+ {
+ /* If -fanalyzer-transitivity is off, we can encounter cases
+ where at least one of the two constraint_managers being merged
+ is infeasible, but we only discover that infeasibility
+ during merging (PR analyzer/96650).
+ Silently drop such constraints. */
+ gcc_assert (!flag_analyzer_transitivity);
+ }
}
}
--- /dev/null
+/* { dg-additional-options "-O2 -fno-analyzer-transitivity" } */
+
+int *wf;
+
+void
+yd (void);
+
+int
+cy (void);
+
+int *
+ee (int hp)
+{
+ if (hp != 0)
+ yd ();
+
+ return 0;
+}
+
+void
+z0 (int co)
+{
+ int l4 = sizeof (int);
+
+ aq:
+ wf = ee (l4);
+ if (l4 < co)
+ l4 = cy () + sizeof (int);
+ goto aq;
+}
--- /dev/null
+/* { dg-additional-options "-O2 -fanalyzer-transitivity" } */
+
+int *wf;
+
+void
+yd (void);
+
+int
+cy (void);
+
+int *
+ee (int hp)
+{
+ if (hp != 0)
+ yd ();
+
+ return 0;
+}
+
+void
+z0 (int co)
+{
+ int l4 = sizeof (int);
+
+ aq:
+ wf = ee (l4);
+ if (l4 < co)
+ l4 = cy () + sizeof (int);
+ goto aq;
+}
--- /dev/null
+/* { dg-additional-options "-fno-analyzer-transitivity" } */
+
+#include "analyzer-decls.h"
+
+int foo (void);
+
+/* Infeasible path, requiring transitivity to find. */
+
+void test_1 (int co, int y)
+{
+ if (4 < co)
+ if (co < y)
+ if (y == 0)
+ __analyzer_dump_path (); /* { dg-message "path" } */
+}
+
+/* Infeasible path, requiring transitivity to find, with a merger. */
+
+void test_2 (int co, int y, int z)
+{
+ if (4 < co)
+ if (co < y)
+ if (y == 0)
+ {
+ while (foo ())
+ {
+ }
+ __analyzer_dump_path (); /* { dg-message "path" } */
+ }
+}
--- /dev/null
+/* { dg-additional-options "-fanalyzer-transitivity" } */
+
+#include "analyzer-decls.h"
+
+int foo (void);
+
+/* Infeasible path, requiring transitivity to find. */
+
+void test_1 (int co, int y)
+{
+ if (4 < co)
+ if (co < y)
+ if (y == 0)
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+}
+
+/* Infeasible path, requiring transitivity to find, with a merger. */
+
+void test_2 (int co, int y, int z)
+{
+ if (4 < co)
+ if (co < y)
+ if (y == 0)
+ {
+ while (foo ())
+ {
+ }
+ __analyzer_dump_path (); /* { dg-bogus "path" } */
+ }
+}