[clang] [clang] Diagnose dangling references for parenthesized aggregate initialization. (PR #117690)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 26 03:45:12 PST 2024
================
@@ -116,6 +116,7 @@ void foo(int n) { // expected-note {{declared here}}
B b2(A(1), {}, 1);
// beforecxx20-warning at -1 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
// beforecxx20-warning at -2 {{aggregate initialization of type 'B' from a parenthesized list of values is a C++20 extension}}
+ // expected-warning at -3 {{temporary whose address is used as value of local variable 'b2' will be destroyed at the end of the full-expression}}
----------------
usx95 wrote:
Can you also add a caae with braced init.
https://godbolt.org/z/EaY8Ess3v
In that case, this should be valid through lifetime extension.
https://github.com/llvm/llvm-project/pull/117690
More information about the cfe-commits
mailing list