From c983608d88adea9d517c53c7055d04fe8a204ef1 Mon Sep 17 00:00:00 2001 From: Benjamin Wolsey Date: Wed, 20 Jul 2011 08:04:01 +0200 Subject: [PATCH 1/2] Test false auto_ptr positive. Assignments after a function returning an auto_ptr is declared are detected as auto_ptr assignments! --- test/teststl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/teststl.cpp b/test/teststl.cpp index ba46c3b3c..09cb55b5a 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1376,6 +1376,12 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:6]: (style) Copy 'auto_ptr' pointer to another do not create two equal objects since one has lost its ownership of the pointer.\n", errout.str()); + check("std::auto_ptr function();\n" + "int quit;" + "void f() { quit = true; }\n" + ); + ASSERT_EQUALS("", errout.str()); + // ticket #748 check("void f() \n" "{\n" From e6d8f3fb733316089e0878ab892529e33cf9d556 Mon Sep 17 00:00:00 2001 From: Benjamin Wolsey Date: Wed, 20 Jul 2011 08:11:35 +0200 Subject: [PATCH 2/2] Fix tested auto_ptr false positive. --- lib/checkstl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 1248ae524..cf00ce976 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1150,7 +1150,10 @@ void CheckStl::checkAutoPointer() autoPointerArrayError(tok2->next()); } } - autoPtrVarId.insert(tok2->next()->varId()); + if (tok2->next()->varId()) + { + autoPtrVarId.insert(tok2->next()->varId()); + } break; } tok2 = tok2->next();