diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 7eaa0decf..4581d6937 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -871,7 +871,7 @@ void CheckOther::switchCaseFallThrough(const Token *tok) //--------------------------------------------------------------------------- static bool isTypeWithoutSideEffects(const Tokenizer *tokenizer, const Variable* var) { - return ((var && (!var->isClass() || var->isPointer()) || Token::simpleMatch(var->typeStartToken(), "std ::")) || !tokenizer->isCPP()); + return ((var && (!var->isClass() || var->isPointer() || Token::simpleMatch(var->typeStartToken(), "std ::"))) || !tokenizer->isCPP()); } void CheckOther::checkSelfAssignment() diff --git a/test/testother.cpp b/test/testother.cpp index d59ed0f35..d43596983 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2309,6 +2309,13 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant assignment of \"var\" to itself\n", errout.str()); + // #4073 (segmentation fault) + check("void Foo::myFunc( int a )\n" + "{\n" + " if (a == 42)\n" + " a = a;\n" + "}\n"); + check("void foo()\n" "{\n" " int x = 1;\n"