-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added CMake option USE_BOOST_INT128
to use a Boost.Multiprecision 128-bit integer for MathLib:big{u}int
#7028
Conversation
Utilizing this to have actual 128-bit support is a long way off. As a first step this allows to iron out the inconsistent usage of the Even if we cannot make it work in the end this would still provide a way for strong type safety we can leverage in the CI. |
As a complement.. if boost is not available and we compile cppcheck with gcc we could use __int128_t for bigints. However __int128_t does not support some math operations as far as I remember :-( I am not sure if a 128-bit bigint is needed. At least not if our goal is only to handle all the 64-bit integers properly. Yes it is unfortunate to use "long long". |
ok that sounds good 👍 |
And Visual Studio has not 128-bit support (yet).
It is - see https://trac.cppcheck.net/ticket/9994. And this was looked into a few years ago already: #3430. |
I suggested here to use a class: The 128-bit integer has problems also. It won't automatically sign extend a signed 8-bit value properly or truncate 16-bit values properly. etc... |
As mentioned above I am not yet looking into getting this working but start with the type safety as a baseline. If that is a given we essentially can replace it with anything - even dropping the whole boost build dependency. That should probably also help with identifying test cases (and possibly existing subtle issues). |
…athLib:big{u}int` [skip ci] Co-authored-by: chrchr-github <chrchr-github@users.noreply.github.com>
@@ -4,6 +4,8 @@ if(MSVC) | |||
endif() | |||
project(Cppcheck VERSION 2.16.99 LANGUAGES CXX) | |||
|
|||
include(cmake/options.cmake) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the top so the default values for the options will be applied here.
@@ -35,6 +39,14 @@ class CPPCHECKLIB MathLib { | |||
friend class TestMathLib; | |||
|
|||
public: | |||
#if defined(HAVE_BOOST) && defined(HAVE_BOOST_INT128) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this because it will later be needed higher up in the class.
USE_BOOST_INT128
to use a 128-bit integer for MathLib:big{u}int
USE_BOOST_INT128
to use a Boost.Multiprecision 128-bit integer for MathLib:big{u}int
No description provided.