From: Richard Biener Date: Wed, 4 Feb 2026 13:44:51 +0000 (+0100) Subject: middle-end/49330 - add testcases for fixed bug X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f845b6995580f7de03b43fef1ad864e3ae28d590;p=thirdparty%2Fgcc.git middle-end/49330 - add testcases for fixed bug Fixed with r14-8796. PR middle-end/49330 * gcc.dg/torture/pr49330-1.c: New testcase. * gcc.dg/torture/pr49330-2.c: Likewise. --- diff --git a/gcc/testsuite/gcc.dg/torture/pr49330-1.c b/gcc/testsuite/gcc.dg/torture/pr49330-1.c new file mode 100644 index 00000000000..3b612a1635d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr49330-1.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +#include + +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 index 00000000000..61cd00dd52e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr49330-2.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ + +#include + +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; +}