From d8fe55203799697bfcf689eee2078e8c88bfc239 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 26 Aug 2025 13:37:49 +0200 Subject: [PATCH] fixed some compiler errors with `USE_BOOST_INT128` --- lib/checkbufferoverrun.cpp | 2 +- lib/checktype.cpp | 2 +- lib/clangimport.cpp | 4 ++-- lib/token.h | 4 ++-- lib/tokenize.cpp | 2 +- lib/valueflow.cpp | 2 +- test/testclangimport.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index a43d5b26ee8..d550f6f474c 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -564,7 +564,7 @@ ValueFlow::Value CheckBufferOverrun::getBufferSize(const Token *bufTok) const if (!var || var->isPointer()) return ValueFlow::Value(-1); - const MathLib::bigint dim = std::accumulate(var->dimensions().cbegin(), var->dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension &dim) { + const MathLib::bigint dim = std::accumulate(var->dimensions().cbegin(), var->dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint i1, const Dimension &dim) { return i1 * dim.num; }); diff --git a/lib/checktype.cpp b/lib/checktype.cpp index aa72013b7ed..92d19c1e794 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -511,7 +511,7 @@ void CheckType::checkFloatToIntegerOverflow(const Token *tok, const ValueType *v bits = mSettings->platform.long_long_bit; else continue; - if (bits < MathLib::bigint_bits && f.floatValue >= (static_cast(1) << bits)) + if (bits < MathLib::bigint_bits && f.floatValue >= (1ULL << bits)) floatToIntegerOverflowError(tok, f); } } diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 8a9a564dd24..9f3bf593755 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -785,7 +785,7 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList) if (nodeType == BreakStmt) return addtoken(tokenList, "break"); if (nodeType == CharacterLiteral) { - const int c = MathLib::toBigNumber(mExtTokens.back()); + const int c = static_cast(MathLib::toBigNumber(mExtTokens.back())); if (c == 0) return addtoken(tokenList, "\'\\0\'"); if (c == '\r') @@ -1582,7 +1582,7 @@ static void setValues(const Tokenizer &tokenizer, const SymbolDatabase *symbolDa MathLib::bigint typeSize = 0; for (const Variable &var: scope.varlist) { - const int mul = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), 1, [](int v, const Dimension& dim) { + const MathLib::bigint mul = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint v, const Dimension& dim) { return v * dim.num; }); if (var.valueType()) diff --git a/lib/token.h b/lib/token.h index fa320cf0520..6ef14af33c1 100644 --- a/lib/token.h +++ b/lib/token.h @@ -778,10 +778,10 @@ class CPPCHECKLIB Token { bool setBits(const MathLib::bigint b) { const MathLib::bigint max = std::numeric_limits::max(); if (b > max) { - mImpl->mBits = max; + mImpl->mBits = static_cast(max); return false; } - mImpl->mBits = b < 0 ? -1 : b; + mImpl->mBits = b < 0 ? -1 : static_cast(b); return true; } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 209cd4f074c..9c6db66a4c6 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10025,7 +10025,7 @@ void Tokenizer::simplifyBitfields() } const auto tooLargeError = [this](const Token *tok) { - const MathLib::bigint max = std::numeric_limits::max(); + const auto max = std::numeric_limits::max(); reportError(tok, Severity::warning, "tooLargeBitField", diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 049e953f59f..7837932f672 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -445,7 +445,7 @@ static Result accumulateStructMembers(const Scope* scope, F f, ValueFlow::Accura if (const ValueType* vt = var.valueType()) { if (vt->type == ValueType::Type::RECORD && vt->typeScope == scope) return {0, false}; - const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension& dim) { + const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint i1, const Dimension& dim) { return i1 * dim.num; }); if (var.nameToken()->scope() != scope && var.nameToken()->scope()->definedType) { // anonymous union diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index f0f74a2b0bc..89f2c7b907a 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -1279,7 +1279,7 @@ class TestClangImport : public TestFixture { ASSERT(!!tok); tok = tok->next(); ASSERT(tok->hasKnownIntValue()); - ASSERT_EQUALS(44, tok->getKnownIntValue()); + ASSERT_EQUALS(MathLib::bigint(44), tok->getKnownIntValue()); } void valueFlow2() {