Current this testcase needs bumped up early inlining limits to work as expected even though all inlining seems to be done by late inline anyway.
I assume this is just about the test and not the implementation of the warning -- so changing Component to testsuite. The --param early-inlining-insns option was added to the test in r276416 presumably to cope with some prior changes to the inlining parameters. The test needs to continue to verify the absence of the warning in the presence of inlining, so if tweaking the --param value in lockstep with the inliner parameters is inconvenient then perhaps the test should force the (already implicitly inline) functions to be inlined by adding attribute always_inline. Does that work for you? (The test passes for me with as well as without the --param option and with the attribute so I'm not sure how to verify the changes have the desired effect.) Please feel free to tweak the test as you see fit yourself just as long as it continues to do what it's supposed to.
Here's what I'm proposing: diff --git a/gcc/testsuite/g++.dg/warn/Wstringop-truncation-1.C b/gcc/testsuite/g++.dg/warn/Wstringop-truncation-1.C index 8f5e7da2c2e..8e2491ca2b3 100644 --- a/gcc/testsuite/g++.dg/warn/Wstringop-truncation-1.C +++ b/gcc/testsuite/g++.dg/warn/Wstringop-truncation-1.C @@ -1,7 +1,7 @@ -/* PR/tree-optimization/84480 - bogus -Wstringop-truncation despite +/* PR tree-optimization/84480 - bogus -Wstringop-truncation despite assignment with an inlined string literal { dg-do compile } - { dg-options "-O2 -Wstringop-truncation --param early-inlining-insns=14" } */ + { dg-options "-O2 -Wstringop-truncation" } */ #include <string.h> @@ -9,7 +9,7 @@ template <size_t N> class GoodString { public: - GoodString (const char *s, size_t slen = N) + __attribute__ ((always_inline)) GoodString (const char *s, size_t slen = N) { if (slen > N) slen = N; @@ -53,7 +53,7 @@ template <size_t N> class BadString1 { public: - BadString1 (const char *s, size_t slen = N) + __attribute__ ((always_inline)) BadString1 (const char *s, size_t slen = N) { if (slen > N) slen = N;
I cannot reproduce the problem here so I'm not working on it. The patch I suggested in comment #2 is just to confirm my understanding of the description in comment #0. Honza, please let me know if it works for you (and feel free to commit it yourself or let me know if you want me to).