From d2d1bf900b1ca3922dbe725a033c2497c7e34dce Mon Sep 17 00:00:00 2001 From: umanamente Date: Mon, 14 May 2018 04:08:33 -0700 Subject: [PATCH] (#8262) Added TODO test for "False positive: memory leak with shared_ptr stored in container" (#1228) --- test/testleakautovar.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 131d22d15..d6b1b46c3 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -141,6 +141,8 @@ private: TEST_CASE(testKeywords); // #6767 TEST_CASE(inlineFunction); // #3989 + + TEST_CASE(smartPtrInContainer); // #8262 } void check(const char code[], bool cpp = false) { @@ -1520,6 +1522,19 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + // #8262 + void smartPtrInContainer() { + check( "std::list< std::shared_ptr > mList;\n" + "void test(){\n" + " int *pt = new int(1);\n" + " mList.push_back(std::shared_ptr(pt));\n" + "}\n", + true + ); + TODO_ASSERT_EQUALS("", "[test.cpp:5]: (error) Memory leak: pt\n", errout.str()); + } + }; REGISTER_TEST(TestLeakAutoVar)