You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testautovariables.cpp
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3955,6 +3955,24 @@ class TestAutoVariables : public TestFixture {
3955
3955
" return a;\n"
3956
3956
"}\n");
3957
3957
ASSERT_EQUALS("", errout_str());
3958
+
3959
+
check("struct A { int& x; };\n"
3960
+
"A f() {\n"
3961
+
" int x = 0;\n"
3962
+
" A a{ .x{x} };\n"
3963
+
" return a;\n"
3964
+
"}\n");
3965
+
ASSERT_EQUALS(
3966
+
"[test.cpp:4:13] -> [test.cpp:3:9] -> [test.cpp:5:12]: (error) Returning object that points to local variable 'x' that will be invalid when returning. [returnDanglingLifetime]\n",
0 commit comments