diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 1b6db105f..581561d67 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4417,7 +4417,7 @@ static const Function* findConstructor(const Scope* scope, const Token* tok, con f = nullptr; std::vector candidates; for (const Function& function : scope->functionList) { - if (function.argCount() != args.size()) + if (function.minArgCount() > args.size()) continue; if (!function.isConstructor()) continue; diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index a76d4e3b0..ee425eda0 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -33,7 +33,7 @@ private: Settings settings; #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], bool inconclusive = false, const char* filename = "test.cpp") { + void check_(const char* file, int line, const char code[], bool inconclusive = true, const char* filename = "test.cpp") { // Clear the error buffer.. errout.str(""); @@ -3675,21 +3675,16 @@ 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" + check("struct C {\n" // #11091 + " C(C& rhs);\n" + " explicit C(const S& n, const S& p = {});\n" + " bool f() const;\n" + " S m;\n" "};\n" - " \n" - "void bar()\n" - "{\n" - " MyClass mutex(\"\");\n" - " while (mutex.IsAnotherRunning())\n" - " DoSomething();\n" - "}"); + "void f() {\n" + " C c(\"\");\n" + " while (c.f()) {}\n" + "}\n"); ASSERT_EQUALS("", errout.str()); check("const int& g(const int& x) {\n"