PR 92829 reports failures in three -Wstringop-overflow tests on
powerpc64*. They seem to be due to VRP determining less than
perfectly accurate range for some of the expressions used by
the tests to set them.
In g:414231ba78973dfcb11648a0a5287b989e0148bb I've committed tweaks
to the tests to avoid this problem. Mainly for the record, I've also
raised bug 93332 for the inaccurate range info that's behind the test
failures.
Martin
commit 414231ba78973dfcb11648a0a5287b989e0148bb
Author: Martin Sebor <mse...@redhat.com>
Date: Mon Jan 20 14:53:33 2020 +0100
PR testsuite/92829 - several -Wstringop-overflow test case failures on powerpc64
* g++.dg/warn/Wstringop-overflow-4.C: Adjust test to avoid failures
due to an aparrent VRP limtation.
* gcc.dg/Wstringop-overflow-25.c: Same.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 67d5f2e9e28..452c16eb8c5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2020-01-20 Martin Sebor <mse...@redhat.com>
+
+ PR testsuite/92829
+ * g++.dg/warn/Wstringop-overflow-4.C: Adjust test to avoid failures
+ due to an aparrent VRP limtation.
+ * gcc.dg/Wstringop-overflow-25.c: Same.
+
2020-01-20 Nathan Sidwell <nat...@acm.org>
PR preprocessor/80005
diff --git a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
index b6fe0289674..121239ac1db 100644
--- a/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
+++ b/gcc/testsuite/g++.dg/warn/Wstringop-overflow-4.C
@@ -98,13 +98,19 @@ void test_strcpy_new_char_array (size_t n)
#ifdef __INT16_TYPE__
+// Hack around PR 92829.
+#define XUR(min, max) \
+ (++idx, (vals[idx] < min || max < vals[idx] ? min : vals[idx]))
+
typedef __INT16_TYPE__ int16_t;
-void test_strcpy_new_int16_t (size_t n)
+void test_strcpy_new_int16_t (size_t n, const size_t vals[])
{
- size_t r_0_1 = UR (0, 1);
- size_t r_1_2 = UR (1, 2);
- size_t r_2_3 = UR (2, 3);
+ size_t idx = 0;
+
+ size_t r_0_1 = XUR (0, 1);
+ size_t r_1_2 = XUR (1, 2);
+ size_t r_2_3 = XUR (2, 3);
T (S (0), new int16_t[r_0_1]);
T (S (1), new int16_t[r_0_1]);
@@ -122,7 +128,7 @@ void test_strcpy_new_int16_t (size_t n)
T (S (6), new int16_t[r_2_3]); // { dg-warning "\\\[-Wstringop-overflow" }
T (S (9), new int16_t[r_2_3]); // { dg-warning "\\\[-Wstringop-overflow" }
- size_t r_2_smax = UR (2, SIZE_MAX);
+ size_t r_2_smax = XUR (2, SIZE_MAX);
T (S (0), new int16_t[r_2_smax]);
T (S (1), new int16_t[r_2_smax]);
T (S (2), new int16_t[r_2_smax]);
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
index 1b38dfe9ae4..01807207acc 100644
--- a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c
@@ -290,11 +290,17 @@ NOIPA void test_strcpy_alloc2_4 (void)
sink (vla); \
} while (0)
-NOIPA void test_strcpy_vla (void)
+// Hack around PR 92829.
+#define XUR(min, max) \
+ (++idx, (vals[idx] < min || max < vals[idx] ? min : vals[idx]))
+
+NOIPA void test_strcpy_vla (const size_t vals[])
{
- size_t r_0_1 = UR (0, 1);
- size_t r_1_2 = UR (1, 2);
- size_t r_2_3 = UR (2, 3);
+ size_t idx = 0;
+
+ size_t r_0_1 = XUR (0, 1);
+ size_t r_1_2 = XUR (1, 2);
+ size_t r_2_3 = XUR (2, 3);
T (char, S (0), r_0_1);
T (char, S (1), r_0_1); // { dg-warning "\\\[-Wstringop-overflow" }