Skip to content

Commit 7a1a378

Browse files
committed
Add test
1 parent bb84926 commit 7a1a378

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
@@ -3947,6 +3947,14 @@ class TestAutoVariables : public TestFixture {
39473947
ASSERT_EQUALS(
39483948
"[test.cpp:4:12] -> [test.cpp:5:12]: (error) Returning object that will be invalid when returning. [returnDanglingLifetime]\n",
39493949
errout_str());
3950+
3951+
check("struct A { int x; int& r};\n"
3952+
"A f(int& r) {\n"
3953+
" int x = 0;\n"
3954+
" A a{.x = x, .r = r};\n"
3955+
" return a;\n"
3956+
"}\n");
3957+
ASSERT_EQUALS("", errout_str());
39503958
}
39513959

39523960
void danglingLifetimeInitList() {

0 commit comments

Comments
 (0)