https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95757
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |85316 CC| |amacleod at redhat dot com Priority|P3 |P1 --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- So the warning machinery (or likely the range machinery) is confused about size_t r_1_2 = UR (1, 2); size_t r_2_3 = UR (2, 3); T (char, S (2), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } T (char, S (0), r_2_3); but it treats the case well when the second T is elided or when the size computation is moved before the Ts like with diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c index bc609587575..116fbf600a6 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-25.c @@ -367,16 +367,16 @@ struct Flex NOIPA void test_strcpy_malloc_flexarray (void) { size_t r_0_1 = UR (0, 1); - size_t r_1_2 = UR (1, 2); - size_t r_2_3 = UR (2, 3); T (char, S (0), r_0_1); T (char, S (1), r_0_1); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } + size_t r_1_2 = UR (1, 2); T (char, S (0), r_1_2); T (char, S (1), r_1_2); T (char, S (2), r_1_2); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } + size_t r_2_3 = UR (2, 3); T (char, S (0), r_2_3); T (char, S (2), r_2_3); T (char, S (3), r_2_3); // { dg-warning "\\\[-Wstringop-overflow" "pr92814" } Martin, is there any harm in changing the testcase this way? The issue reproduces with a cross and the two-line snippet at the top (just prune the rest from the testcase). In case you want to have a closer look why the warning is not issued on ppc64le (where I tested) vs. x86_64. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316 [Bug 85316] [meta-bug] VRP range propagation missed cases