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>
| endif() | ||
| project(Cppcheck VERSION 2.16.99 LANGUAGES CXX) | ||
|
|
||
| include(cmake/options.cmake) |
There was a problem hiding this comment.
Moved to the top so the default values for the options will be applied here.
| friend class TestMathLib; | ||
|
|
||
| public: | ||
| #if defined(HAVE_BOOST) && defined(HAVE_BOOST_INT128) |
There was a problem hiding this comment.
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}intUSE_BOOST_INT128 to use a Boost.Multiprecision 128-bit integer for MathLib:big{u}int
No description provided.