CPROVER Manual TOC

## Build Systems and Libraries

### Architectural Settings

The behavior of a C/C++ program depends on a number of parameters that are specific to the architecture the program was compiled for. The three most important architectural parameters are:

- The width of the various scalar types; e.g., compare the value of `sizeof(long int)` on various machines.
- The width of pointers; e.g., compare the value of `sizeof(int *)` on various machines.
- The endianness of the architecture.

In general, the CPROVER tools attempt to adopt the settings of the particular architecture the tool itself was compiled for. For example, when running a 64 bit binary of CBMC on Linux, the program will be processed assuming that `sizeof(long int)==8`.

As a consequence of these architectural parameters, you may observe different verification results for an identical program when running CBMC on different machines. In order to get consistent results, or when aiming at validating a program written for a different platform, the following command-line arguments can be passed to the CPROVER tools:

- The word-width can be set with `--16`, `--32`, `--64`.
- The endianness can be defined with `--little-endian` and `--big-endian`.

When using a goto binary, CBMC and the other tools read the configuration from the binary, i.e., the setting when running goto-cc is the one that matters; the option given to the model checker is ignored in this case.

In order to see the effect of the options `--16`, `--32` and `--64`, pass the following program to CBMC:

`#include <stdio.h>
#include <assert.h>
int main() {
printf("sizeof(long int): %d\n", (int)sizeof(long int));
printf("sizeof(int *): %d\n", (int)sizeof(int *));
assert(0);
}`

The counterexample trace contains the strings printed by the `printf` command.

The effects of endianness are more subtle. Try the following program with `--big-endian` and `--little-endian`:

`#include <stdio.h>
#include <assert.h>
int main() {
int i=0x01020304;
char *p=(char *)&i;
printf("Bytes of i: %d, %d, %d, %d\n",
p[0], p[1], p[2], p[3]);
assert(0);
}`