Skip to content

Commit ba1f8fd

Browse files
Update testautovariables.cpp
1 parent 834570e commit ba1f8fd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/testautovariables.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,6 +4062,14 @@ class TestAutoVariables : public TestFixture {
40624062
" struct S s = { .i = 0, true };\n"
40634063
"}\n"); // don't crash
40644064
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",
4072+
errout_str());
40654073
}
40664074

40674075
void danglingLifetimeInitList() {

0 commit comments

Comments
 (0)