Bug 91955 - g++.dg/warn/Wstringop-truncation-1.C should not rely on early inlinng
Summary: g++.dg/warn/Wstringop-truncation-1.C should not rely on early inlinng
Status: WAITING
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Jan Hubicka
URL:
Keywords: diagnostic
Depends on:
Blocks: Wstringop-truncation
  Show dependency treegraph
 
Reported: 2019-10-01 17:04 UTC by Jan Hubicka
Modified: 2022-10-23 00:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-01-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2019-10-01 17:04:31 UTC
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.
Comment 1 Martin Sebor 2020-01-14 09:59:14 UTC
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.
Comment 2 Martin Sebor 2020-01-14 10:03:05 UTC
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;
Comment 3 Martin Sebor 2020-01-29 16:16:47 UTC
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).