From f77d4267066867b4f3b14068519d69eb456c828f Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Tue, 19 May 2026 15:35:20 +0100 Subject: [PATCH] C++: Add test demonstrating broken phi cycle certain'ness. --- .../library-tests/dataflow/certain/test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cpp/ql/test/library-tests/dataflow/certain/test.cpp b/cpp/ql/test/library-tests/dataflow/certain/test.cpp index 8ec99673e90..eece48c2ea3 100644 --- a/cpp/ql/test/library-tests/dataflow/certain/test.cpp +++ b/cpp/ql/test/library-tests/dataflow/certain/test.cpp @@ -61,4 +61,22 @@ void test3(bool b) { // $ certain="SSA def(&b)" certain="SSA def(b)" } use(i); // $ certain="SSA phi(i)" } +} + +void test(int x, bool b1, bool b2) { // $ certain="SSA def(&x)" certain="SSA def(x)" certain="SSA def(&b1)" certain="SSA def(b1)" certain="SSA def(&b2)" certain="SSA def(b2)" + int* p = &x; // $ certain="SSA def(&p)" certain="SSA def(p)" certain="SSA def(*p)" + int i = 0; // $ certain="SSA def(&i)" certain="SSA def(i)" + int j = 0; // $ certain="SSA def(&j)" certain="SSA def(j)" + while (i < 10) { // $ certain="SSA phi(i)" uncertain="SSA phi(*p)" + if (b1) { + *p = 0; // $ certain="SSA def(*p)" + } + ++i; // $ certain="SSA def(i)" uncertain="SSA phi(*p)" + } + while (j < 10) { // $ uncertain="SSA phi(*p)" certain="SSA phi(j)" + if (b2) { + *(p + j) = 0; // $ uncertain="SSA def(*p)" + } + ++j; // $ certain="SSA def(j)" uncertain="SSA phi(*p)" + } } \ No newline at end of file