Skip to content

Commit

Permalink
Update testautovariables.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jan 16, 2025
1 parent 339be91 commit d070e5a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TestAutoVariables : public TestFixture {
TEST_CASE(danglingLifetime);
TEST_CASE(danglingLifetimeFunction);
TEST_CASE(danglingLifetimeUserConstructor);
TEST_CASE(danglingLifetimeAggegrateConstructor);
TEST_CASE(danglingLifetimeAggregateConstructor);
TEST_CASE(danglingLifetimeInitList);
TEST_CASE(danglingLifetimeImplicitConversion);
TEST_CASE(danglingTemporaryLifetime);
Expand Down Expand Up @@ -3796,7 +3796,7 @@ class TestAutoVariables : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void danglingLifetimeAggegrateConstructor() {
void danglingLifetimeAggregateConstructor() {
check("struct A {\n"
" const int& x;\n"
" int y;\n"
Expand Down Expand Up @@ -3893,6 +3893,17 @@ class TestAutoVariables : public TestFixture {
" return { m.data() };\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("struct S { std::string s; };\n" // #13167
"std::vector<S> f() {\n"
" std::vector<S> v;\n"
" {\n"
" std::string a{ \"abc\" };\n"
" v.push_back({ a.c_str() });\n"
" }\n"
" return v;\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void danglingLifetimeInitList() {
Expand Down

0 comments on commit d070e5a

Please sign in to comment.