You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testautovariables.cpp
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2937,6 +2937,30 @@ class TestAutoVariables : public TestFixture {
2937
2937
" return it;\n"
2938
2938
"}\n");
2939
2939
ASSERT_EQUALS("[test.cpp:3:44] -> [test.cpp:2:22] -> [test.cpp:4:12]: (error) Returning iterator to local container 'x' that will be invalid when returning. [returnDanglingLifetime]\n", errout_str());
2940
+
2941
+
check("void f(std::vector<int*>& m) {\n"
2942
+
" int x;\n"
2943
+
" m.push_back(&x);\n"
2944
+
"}\n");
2945
+
ASSERT_EQUALS("[test.cpp:3:17] -> [test.cpp:3:17] -> [test.cpp:2:9] -> [test.cpp:3:5]: (error) Non-local variable 'm' will use object that points to local variable 'x'. [danglingLifetime]\n", errout_str());
0 commit comments