diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 06a083121..66f33e93e 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -74,7 +74,9 @@ static const char * getFunctionTypeName(Function::Type type) static bool isVariableCopyNeeded(const Variable &var) { - return var.isPointer() || (var.type() && var.type()->needInitialization == Type::NeedInitialization::True) || (var.valueType()->type >= ValueType::Type::CHAR); + return var.isPointer() || + (var.type() && var.type()->needInitialization == Type::NeedInitialization::True) || + (var.valueType() && var.valueType()->type >= ValueType::Type::CHAR); } //--------------------------------------------------------------------------- diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 52dafa11a..c3b4a1b40 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -196,6 +196,8 @@ private: TEST_CASE(uninitComparisonAssignment); // ticket #7429 TEST_CASE(uninitTemplate1); // ticket #7372 + + TEST_CASE(unknownTemplateType); } @@ -3903,6 +3905,18 @@ private: "A>::A() : m_value(false) {}\n"); ASSERT_EQUALS("", errout.str()); } + + void unknownTemplateType() { + check("template class A {\n" + "private:\n" + " T m;\n" + "public:\n" + " A& operator=() { return *this; }\n" + "};\n" + "A a;"); + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestConstructors)