diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index f793891de..09d0589cb 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -181,7 +181,7 @@ void CheckExceptionSafety::checkCatchExceptionByValue() static const Token * functionThrowsRecursive(const Function * function, std::set & recursive) { // check for recursion and bail if found - if (recursive.find(function) != recursive.end()) + if (!recursive.insert(function).second) return nullptr; if (!function->functionScope) diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index 30206bc9d..401808197 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -46,6 +46,7 @@ private: TEST_CASE(nothrowThrow); TEST_CASE(unhandledExceptionSpecification); // #4800 TEST_CASE(nothrowAttributeThrow); + TEST_CASE(nothrowAttributeThrow2); // #5703 } void check(const char code[], bool inconclusive = false) { @@ -372,6 +373,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void nothrowAttributeThrow2() { + check("class foo {\n" + " void copyMemberValues() throw () {\n" + " copyMemberValues();\n" + " }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestExceptionSafety)