aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2025-01-31 12:39:34 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2025-01-31 12:39:34 +0100
commit9fc0683082067801e3790f7cfffedbf5441e0f82 (patch)
treeb5a7f21b8c55577d4945aba410fce8bf7b3de101 /gcc
parent5f34558100e8466aa70373e2f930bf1013192ba8 (diff)
downloadgcc-9fc0683082067801e3790f7cfffedbf5441e0f82.zip
gcc-9fc0683082067801e3790f7cfffedbf5441e0f82.tar.gz
gcc-9fc0683082067801e3790f7cfffedbf5441e0f82.tar.bz2
testsuite: Add testcase for already fixed PR [PR117498]
This wrong-code issue has been fixed with r15-7249. We still emit warnings which are questionable and perhaps we'd get better generated code if niters determined the loop has only a single iteration without UB and we'd punt on vectorizing it (or unrolling). 2025-01-31 Jakub Jelinek <jakub@redhat.com> PR middle-end/117498 * gcc.c-torture/execute/pr117498.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr117498.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr117498.c b/gcc/testsuite/gcc.c-torture/execute/pr117498.c
new file mode 100644
index 0000000..085c6b6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr117498.c
@@ -0,0 +1,35 @@
+/* PR middle-end/117498 */
+
+int a, d, f;
+char g;
+volatile int c = 1;
+
+int
+foo ()
+{
+ if (c == 0)
+ return -1;
+ return 1;
+}
+
+void
+bar (int h, int i, char *k, char *m)
+{
+ for (; d < i; d += 2)
+ for (int j = 0; j < h; j++)
+ m[j] = k[4 * j];
+}
+
+void
+baz (long h)
+{
+ char n = 0;
+ bar (h, 4, &n, &g);
+}
+
+int
+main ()
+{
+ f = foo ();
+ baz ((unsigned char) f - 4);
+}