https://gcc.gnu.org/g:166d5ff483f9410cea2f41c1a263918eeeffa18f

commit r16-8431-g166d5ff483f9410cea2f41c1a263918eeeffa18f
Author: Andrew Pinski <[email protected]>
Date:   Tue Mar 17 17:13:55 2026 -0700

    testsuite/c++: Fix lifetime issue in func-params-07.C [PR124548]
    
    So compiling this testcase with -fsantize=address we get an use
    after the lifetime is gone. In this case it is the rvalue reference
    argument to my_coro. With more inlining into main, this testcase
    started to fail at -O3 as we remove the store to the temporary now
    as the access is after the lifetime of the temporary has ended.
    The best way of fixing this is creating an rvalue reference that will
    then forward into the argument. This means we have the rvalue reference
    no longer as a temporary that ends at the end of the statement but rather
    end of the scope (since it is extended).
    
    Tested on x86_64-linux-gnu with the testcase now passing at -O3.
    
            PR testsuite/124548
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/coroutines/torture/func-params-07.C (main): Fix lifetime
            issue of rvalue reference.
    
    Signed-off-by: Andrew Pinski <[email protected]>

Diff:
---
 gcc/testsuite/g++.dg/coroutines/torture/func-params-07.C | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/coroutines/torture/func-params-07.C 
b/gcc/testsuite/g++.dg/coroutines/torture/func-params-07.C
index 03044ef4b314..37ff08d73f55 100644
--- a/gcc/testsuite/g++.dg/coroutines/torture/func-params-07.C
+++ b/gcc/testsuite/g++.dg/coroutines/torture/func-params-07.C
@@ -21,7 +21,8 @@ int main ()
   PRINT ("main: create coro1");
   int lv = 1;
   int lvr = 2;
-  coro1 x = my_coro (lv, lvr, lvr+2);
+  int &&rvr = lvr+2;
+  coro1 x = my_coro (lv, lvr, std::forward<int>(rvr));
 
   if (x.handle.done())
     abort();

Reply via email to