diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 98085b740..4f68418da 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2537,6 +2537,8 @@ void CheckOther::checkEvaluationOrder() continue; if (tok3->str() == "&" && !tok3->astOperand2()) continue; // don't handle adress-of for now + if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof")) + continue; // don't care about sizeof usage tokens.push(tok3->astOperand1()); tokens.push(tok3->astOperand2()); if (isSameExpression(_tokenizer->isCPP(), false, tok->astOperand1(), tok3, _settings->library.functionpure)) { diff --git a/test/testother.cpp b/test/testother.cpp index d44726f03..b5e20882c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6143,6 +6143,12 @@ private: "}", "test.c"); TODO_ASSERT_EQUALS("error", "", errout.str()); } + + // sizeof + check("void f(char *buf) {\n" + " dostuff(buf++, sizeof(*buf));" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); } };