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
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4062,6 +4062,14 @@ class TestAutoVariables : public TestFixture {
4062
4062
" struct S s = { .i = 0, true };\n"
4063
4063
"}\n"); // don't crash
4064
4064
ASSERT_EQUALS("", errout_str());
4065
+
4066
+
check("struct A { int& r; };\n"// #14772
4067
+
"A* f() {\n"
4068
+
" int x = 0;\n"
4069
+
" return new A{ x };\n"
4070
+
"}\n");
4071
+
ASSERT_EQUALS("[test.cpp:4:19] -> [test.cpp:3:9] -> [test.cpp:4:17]: (error) Returning object that points to local variable 'x' that will be invalid when returning. [returnDanglingLifetime]\n",
0 commit comments