diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index a72dee915..c33f49bd7 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -62,7 +62,14 @@ void Check64BitPortability::pointerassignment() assignmentIntegerToAddressError(tok->next()); else if (isint(var1) && isaddr(var2) && !tok->tokAt(3)->isPointerCompare()) + { + // assigning address => warning + // some trivial addition => warning + if (Token::Match(tok->tokAt(4), "+ %any% !!;")) + continue; + assignmentAddressToIntegerError(tok->next()); + } } } } diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 3f329992d..bfc0f7e8e 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -140,6 +140,12 @@ private: " int *a = x * x;\n" "}\n"); TODO_ASSERT_EQUALS("error", "", errout.str()); + + check("void foo(int *start, int *end) {\n" + " int len;\n" + " int len = end + 10 - start;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } };