diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a03e4bd6b54..40fd10a97d4 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2999,7 +2999,7 @@ void CheckOther::checkNegativeBitwiseShift() // don't warn if lhs is a class. this is an overloaded operator then if (tok->isCpp()) { const ValueType * lhsType = tok->astOperand1()->valueType(); - if (!lhsType || !lhsType->isIntegral()) + if (!lhsType || !lhsType->isIntegral() || lhsType->pointer) continue; } diff --git a/test/testother.cpp b/test/testother.cpp index 3c488a7d013..da58be85e81 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -9113,6 +9113,13 @@ class TestOther : public TestFixture { "[test.cpp:2]: (error) Shifting by a negative value is undefined behaviour\n" "[test.cpp:3]: (portability) Shifting a negative value is technically undefined behaviour\n" "[test.cpp:4]: (portability) Shifting a negative value is technically undefined behaviour\n", errout_str()); + + check("void f(int i) {\n" // #12916 + " if (i < 0) {\n" + " g(\"abc\" << i);\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void incompleteArrayFill() {