diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 764bbb447..2ecba108f 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -490,6 +490,9 @@ void CheckOther::checkRedundantAssignment() if (!nextAssign) continue; + + if (nextAssign == tok) + continue; // there is redundant assignment. Is there a case between the assignments? bool hasCase = false; diff --git a/test/testother.cpp b/test/testother.cpp index f6dfcb898..566e8f504 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -5968,6 +5968,14 @@ private: " memptr = 0;\n" "}"); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (style) Variable 'memptr' is reassigned a value before the old one has been used.\n", errout.str()); + + // issue #8884 + check("template \n" + "auto foo(F f, Ts... xs) {\n" + " auto x = f(xs...);\n" + " return x;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void redundantVarAssignment_struct() {