Skip to content

Commit 4148183

Browse files
Update testautovariables.cpp
1 parent 10c73fc commit 4148183

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/testautovariables.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,6 +3957,15 @@ class TestAutoVariables : public TestFixture {
39573957
"[test.cpp:6:30] -> [test.cpp:6:30] -> [test.cpp:6:21] -> [test.cpp:5:21] -> [test.cpp:8:12]: (error) Returning object that points to local variable 'a' that will be invalid when returning. [returnDanglingLifetime]\n",
39583958
errout_str());
39593959

3960+
check("struct S { const std::string& r; };\n" // #14209
3961+
"S f() {\n"
3962+
" std::string s;\n"
3963+
" return S{ s };\n"
3964+
"}\n");
3965+
ASSERT_EQUALS(
3966+
"[test.cpp:4:15] -> [test.cpp:3:17] -> [test.cpp:4:13]: (error) Returning object that points to local variable 's' that will be invalid when returning. [returnDanglingLifetime]\n",
3967+
errout_str());
3968+
39603969
check("struct A { int& x; };\n" // #14247
39613970
"A f() {\n"
39623971
" int x = 0;\n"

0 commit comments

Comments
 (0)