From 85e31b5c8530775ff7377e1717c7709398e9abe8 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:13:06 +0200 Subject: [PATCH 1/2] Update checkother.cpp --- lib/checkother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 1a29cd9d26e8812473cbc717bab350fd57d61f90 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:15:50 +0200 Subject: [PATCH 2/2] Update testother.cpp --- test/testother.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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() {