Fixed #7807 (false positive: (error) Signed integer overflow for expression 'int32_max-1'.)
This commit is contained in:
parent
1245f1d621
commit
4de5dc75aa
|
@ -117,7 +117,7 @@ void CheckType::checkIntegerOverflow()
|
|||
return;
|
||||
|
||||
// max int value according to platform settings.
|
||||
const MathLib::bigint maxint = (1LL << (_settings->int_bit - 2)) - 1;
|
||||
const MathLib::bigint maxint = (1LL << (_settings->int_bit - 1)) - 1;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
|
|
@ -113,6 +113,12 @@ private:
|
|||
"}",&settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Signed integer overflow for expression 'intmax+1'.\n", errout.str());
|
||||
|
||||
check("void foo() {\n"
|
||||
" int intmax = 0x7fffffff;\n"
|
||||
" return intmax - 1;\n"
|
||||
"}",&settings);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int foo(signed int x) {\n"
|
||||
" if (x==123456) {}\n"
|
||||
" return x * x;\n"
|
||||
|
|
Loading…
Reference in New Issue