Skip to content

Commit

Permalink
Add test for #10995
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Jan 16, 2025
1 parent 08f8d60 commit 680806f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,14 @@ class TestAutoVariables : public TestFixture {
ASSERT_EQUALS(
"[test.cpp:3] -> [test.cpp:2] -> [test.cpp:3]: (error) Returning pointer to local variable 'a' that will be invalid when returning.\n",
errout_str());

check("std::string_view f() {\n" // #10995
" char a[10]{};\n"
" return a;\n"
"}\n");
ASSERT_EQUALS(
"[test.cpp:3] -> [test.cpp:2] -> [test.cpp:3]: (error) Returning pointer to local variable 'a' that will be invalid when returning.\n",
errout_str());
}

void danglingLifetimeUniquePtr()
Expand Down

0 comments on commit 680806f

Please sign in to comment.