Description
Currently it is not possible to produce a 32-bit build of CBMC with -Wall -Wpedantic -Werror
set. This is because there is a cast from 2<<32
to size_t
which gets truncated to 0
on 32-bit platforms (in interpreter.cpp
).
There have been several attempts to fix this problem.
The first attempt, #987, solves the problem by reducing the shift amount to 1<<32
. It is not clear why this PR was not accepted.
The second attempt, #1330, keeps the shift amount at 2<<32
and attempts to solve the problem by using mp_integer
wherever possible in the interpreter in order to avoid truncation altogether. However, to facilitate minimal changes in this patch, the binary operators in mp_integer
had to be changed to allow conversions on both sides of operators (it's surprising to have BigInt + size_t
work, but size_t + BigInt
result in a compile error - associative operators should be really associative). As a result, #1330 depends on #1341.
There were concerns about the performance implications of the new mp_integer
operators in #1341, which may introduce conversions which weren't required before. It is not practical for me to build a benchmarking suite (this would be an enormous undertaking and I do not have the necessary expertise in either benchmarking or the customer requirements), and so #1341 will not be merge-able in the near future.