Added regression test for ticket #11091 - FP: Using object that is a temporary

This commit is contained in:
orbitcowboy 2022-09-24 22:11:04 +02:00
parent 70c844ddfb
commit 2bdeaf858e
1 changed files with 17 additions and 0 deletions

View File

@ -3517,6 +3517,23 @@ private:
}
void danglingTemporaryLifetime() {
check("struct MyClass\n" // FP - #11091
"{\n"
" MyClass(MyClass& rhs);\n"
" explicit MyClass(const wxString& name, const wxString& path = {});\n"
" bool IsAnotherRunning() const;\n"
" \n"
" wxString m_fn;\n"
"};\n"
" \n"
"void bar()\n"
"{\n"
" MyClass mutex(\"\");\n"
" while (mutex.IsAnotherRunning())\n"
" DoSomething();\n"
"}");
ASSERT_EQUALS("", errout.str());
check("const int& g(const int& x) {\n"
" return x;\n"
"}\n"