]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/49330 - add testcases for fixed bug
authorRichard Biener <rguenther@suse.de>
Wed, 4 Feb 2026 13:44:51 +0000 (14:44 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 4 Feb 2026 13:46:31 +0000 (14:46 +0100)
Fixed with r14-8796.

PR middle-end/49330
* gcc.dg/torture/pr49330-1.c: New testcase.
* gcc.dg/torture/pr49330-2.c: Likewise.

gcc/testsuite/gcc.dg/torture/pr49330-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr49330-2.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/torture/pr49330-1.c b/gcc/testsuite/gcc.dg/torture/pr49330-1.c
new file mode 100644 (file)
index 0000000..3b612a1
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+#include <stdint.h>
+
+int x, y;
+int __attribute__((noipa)) foo()
+{
+  uintptr_t px = (uintptr_t) &x;
+  uintptr_t py = (uintptr_t) &y;
+  volatile uintptr_t d = px - py;
+  uintptr_t p = py + d;
+  x = 1;
+  *(int *) p = 2;
+  return x;
+}
+
+int main()
+{
+  if (foo () != 2)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49330-2.c b/gcc/testsuite/gcc.dg/torture/pr49330-2.c
new file mode 100644 (file)
index 0000000..61cd00d
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+#include <stdio.h>
+
+int a;
+
+void __attribute__((noipa))
+foo()
+{
+  unsigned long b = (unsigned long) &a - 134518548;
+  volatile unsigned long c = b;
+  if (c == 0) {
+    if (b != 0) __builtin_abort ();
+  }
+  a = c;
+}
+
+int main()
+{
+  foo ();
+  return 0;
+}