Skip to content

Commit 557f4bf

Browse files
authored
Merge pull request #6479 from NlightNFotis/warn_unsound_flags
Warn user when unsound flags are enabled.
2 parents 1efed70 + fde9ac5 commit 557f4bf

20 files changed

+265
-124
lines changed

doc/cprover-manual/api.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[CPROVER Manual TOC](../)
22

3-
## The CPROVER API Reference
3+
# The CPROVER API Reference
44

55
The following sections summarize the functions available to programs
66
that are passed to the CPROVER tools.
77

8-
### Functions
8+
## Functions
99

10-
#### \_\_CPROVER\_assume, \_\_CPROVER\_assert, assert
10+
### \_\_CPROVER\_assume, \_\_CPROVER\_assert, assert
1111

1212
```C
1313
void __CPROVER_assume(_Bool assumption);
@@ -20,7 +20,7 @@ to the program. If the expression evaluates to false, the execution
2020
aborts without failure. More detail on the use of assumptions is in the
2121
section on [Assumptions](../modeling/assumptions/).
2222
23-
#### \_\_CPROVER\_input, \_\_CPROVER\_output
23+
### \_\_CPROVER\_input, \_\_CPROVER\_output
2424
2525
```C
2626
void __CPROVER_input(const char *id, ...);
@@ -35,7 +35,7 @@ using nondeterminism, as described [here](../modeling/nondeterminism/)). The
3535
string constant is followed by an arbitrary number of values of
3636
arbitrary types.
3737

38-
#### \_\_CPROVER\_printf
38+
### \_\_CPROVER\_printf
3939

4040
```C
4141
void __CPROVER_printf(const char *format, ...);
@@ -45,7 +45,7 @@ The function **\_\_CPROVER\_printf** implements the C `printf` function (without
4545
any return value). The observable effect is that its output is shown within a
4646
counterexample trace.
4747
48-
#### \_\_CPROVER\_cover
48+
### \_\_CPROVER\_cover
4949
5050
```C
5151
void __CPROVER_cover(_Bool condition);
@@ -54,7 +54,7 @@ void __CPROVER_cover(_Bool condition);
5454
This statement defines a custom coverage criterion, for usage with the
5555
[test suite generation feature](../test-suite/).
5656

57-
#### \_\_CPROVER\_isnan, \_\_CPROVER\_isfinite, \_\_CPROVER\_isinf, \_\_CPROVER\_isnormal, \_\_CPROVER\_sign
57+
### \_\_CPROVER\_isnan, \_\_CPROVER\_isfinite, \_\_CPROVER\_isinf, \_\_CPROVER\_isnormal, \_\_CPROVER\_sign
5858

5959
```C
6060
_Bool __CPROVER_isnan(double f);
@@ -83,7 +83,7 @@ number.
8383
This function **\_\_CPROVER\_sign** returns true if the double-precision
8484
floating-point number passed as argument is negative.
8585
86-
#### \_\_CPROVER\_abs, \_\_CPROVER\_labs, \_\_CPROVER\_fabs, \_\_CPROVER\_fabsl, \_\_CPROVER\_fabsf
86+
### \_\_CPROVER\_abs, \_\_CPROVER\_labs, \_\_CPROVER\_fabs, \_\_CPROVER\_fabsl, \_\_CPROVER\_fabsf
8787
8888
```C
8989
int __CPROVER_abs(int x);
@@ -95,7 +95,7 @@ float __CPROVER_fabsf(float x);
9595

9696
These functions return the absolute value of the given argument.
9797

98-
#### \_\_CPROVER\_overflow\_minus, \_\_CPROVER\_overflow\_mult, \_\_CPROVER\_overflow\_plus, \_\_CPROVER\_overflow\_shl, \_\_CPROVER\_overflow\_unary\_minus
98+
### \_\_CPROVER\_overflow\_minus, \_\_CPROVER\_overflow\_mult, \_\_CPROVER\_overflow\_plus, \_\_CPROVER\_overflow\_shl, \_\_CPROVER\_overflow\_unary\_minus
9999

100100
```C
101101
__CPROVER_bool __CPROVER_overflow_minus();
@@ -111,7 +111,7 @@ operation would overflow when applied to the arguments. For example,
111111
`__CPROVER_overflow_plus(x, y)` returns true if `x + y` would result in an
112112
arithmetic overflow.
113113

114-
#### \_\_CPROVER\_array\_equal, \_\_CPROVER\_array\_copy, \_\_CPROVER\_array\_set
114+
### \_\_CPROVER\_array\_equal, \_\_CPROVER\_array\_copy, \_\_CPROVER\_array\_set
115115

116116
```C
117117
_Bool __CPROVER_array_equal(const void array1[], const void array2[]);
@@ -126,7 +126,7 @@ the array **dest**. The function **\_\_CPROVER\_array\_set** initializes
126126
the array **dest** with the given value.
127127
128128
129-
#### \_\_CPROVER\_enum\_is\_in\_range
129+
### \_\_CPROVER\_enum\_is\_in\_range
130130
131131
```C
132132
__CPROVER_bool __CPROVER_enum_is_in_range();
@@ -157,16 +157,16 @@ int main()
157157
```
158158

159159

160-
#### Uninterpreted Functions
160+
## Uninterpreted Functions
161161

162-
Uninterpreted functions are documented [here](../modeling/nondeterminism/)).
162+
Uninterpreted functions are documented [here](../modeling/nondeterminism/).
163163

164-
### Memory-Related Functions
164+
## Memory-Related Functions
165165

166166
The semantics of the primitives listed in this section is described in more detail in the
167167
document about [Memory Primitives](../memory-primitives/).
168168

169-
#### \_\_CPROVER\_POINTER\_OBJECT, \_\_CPROVER\_POINTER\_OFFSET, \_\_CPROVER\_same\_object
169+
### \_\_CPROVER\_POINTER\_OBJECT, \_\_CPROVER\_POINTER\_OFFSET, \_\_CPROVER\_same\_object
170170

171171
```C
172172
__CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *p);
@@ -180,7 +180,7 @@ offset of the given pointer relative to the base address of the object. The
180180
function **\_\_CPROVER\_same\_object** returns true if the two pointers given as
181181
arguments point to the same object.
182182
183-
#### \_\_CPROVER\_OBJECT\_SIZE, \_\_CPROVER\_DYNAMIC\_OBJECT, \_\_CPROVER\_r\_ok, \_\_CPROVER\_w\_ok
183+
### \_\_CPROVER\_OBJECT\_SIZE, \_\_CPROVER\_DYNAMIC\_OBJECT, \_\_CPROVER\_r\_ok, \_\_CPROVER\_w\_ok
184184
185185
The following primitives require a pointer that is null or valid in order to
186186
have well-defined semantics in all usage cases. See the document about
@@ -211,7 +211,7 @@ returns true when it is safe to do both. These predicates can be given an
211211
optional size; when the size argument is not given, the size of the subtype
212212
(which must not be **void**) of the pointer type is used.
213213

214-
#### \_\_CPROVER\_havoc\_object
214+
### \_\_CPROVER\_havoc\_object
215215

216216

217217
This function requires a valid pointer and updates **all bytes** of the
@@ -243,7 +243,7 @@ __CPROVER_assert(thefoo.y == 2, "fails because `thefoo.y` is now nondet");
243243
__CPROVER_assert(thefoo.z == 3, "fails because `thefoo.z` is now nondet");
244244
```
245245

246-
#### \_\_CPROVER\_havoc\_slice
246+
### \_\_CPROVER\_havoc\_slice
247247

248248
This function requires requires that `__CPROVER_w_ok(p, size)` holds,
249249
and updates `size` consecutive bytes of the underlying object, starting at `p`,
@@ -262,9 +262,9 @@ void __CPROVER_havoc_slice(void *p, __CPROVER_size_t size);
262262
by the program, then havocing the slice is equivalent to making the
263263
interpretation of these bytes nondeterministic.
264264
265-
### Predefined Types and Symbols
265+
## Predefined Types and Symbols
266266
267-
#### \_\_CPROVER\_bitvector
267+
### \_\_CPROVER\_bitvector
268268
269269
```C
270270
__CPROVER_bitvector [ expression ]
@@ -275,7 +275,7 @@ bit vector with arbitrary but fixed size. The usual integer type
275275
modifiers **signed** and **unsigned** can be applied. The usual
276276
arithmetic promotions will be applied to operands of this type.
277277

278-
#### \_\_CPROVER\_floatbv
278+
### \_\_CPROVER\_floatbv
279279

280280
```C
281281
__CPROVER_floatbv [ expression ] [ expression ]
@@ -287,7 +287,7 @@ parameter is the total size (in bits) of the number, and the second is
287287
the size (in bits) of the mantissa, or significand (not including the
288288
hidden bit, thus for single precision this should be 23).
289289

290-
#### \_\_CPROVER\_fixedbv
290+
### \_\_CPROVER\_fixedbv
291291

292292
```C
293293
__CPROVER_fixedbv [ expression ] [ expression ]
@@ -298,51 +298,51 @@ fixed-point bit vector with arbitrary but fixed size. The first
298298
parameter is the total size (in bits) of the type, and the second is the
299299
number of bits after the radix point.
300300

301-
#### \_\_CPROVER\_size\_t
301+
### \_\_CPROVER\_size\_t
302302

303303
The type of sizeof expressions.
304304

305-
#### \_\_CPROVER\_rounding\_mode
305+
### \_\_CPROVER\_rounding\_mode
306306

307307
```C
308308
extern int __CPROVER_rounding_mode;
309309
```
310310

311311
This variable contains the IEEE floating-point arithmetic rounding mode.
312312

313-
#### \_\_CPROVER\_constant\_infinity\_uint
313+
### \_\_CPROVER\_constant\_infinity\_uint
314314

315315
This is a constant that models a large unsigned integer.
316316

317-
#### \_\_CPROVER\_integer, \_\_CPROVER\_rational
317+
### \_\_CPROVER\_integer, \_\_CPROVER\_rational
318318

319319
**\_\_CPROVER\_integer** is an unbounded, signed integer type.
320320
**\_\_CPROVER\_rational** is an unbounded, signed rational number type.
321321

322-
#### \_\_CPROVER\_memory
322+
### \_\_CPROVER\_memory
323323

324324
```C
325325
extern unsigned char __CPROVER_memory[];
326326
```
327327

328328
This array models the contents of integer-addressed memory.
329329

330-
#### \_\_CPROVER::unsignedbv<N> (C++ only)
330+
### \_\_CPROVER::unsignedbv<N> (C++ only)
331331

332332
This type is the equivalent of **unsigned \_\_CPROVER\_bitvector\[N\]**
333333
in the C++ front-end.
334334

335-
#### \_\_CPROVER::signedbv<N> (C++ only)
335+
### \_\_CPROVER::signedbv<N> (C++ only)
336336

337337
This type is the equivalent of **signed \_\_CPROVER\_bitvector\[N\]** in
338338
the C++ front-end.
339339

340-
#### \_\_CPROVER::fixedbv<N> (C++ only)
340+
### \_\_CPROVER::fixedbv<N> (C++ only)
341341

342342
This type is the equivalent of **\_\_CPROVER\_fixedbv\[N,m\]** in the
343343
C++ front-end.
344344

345-
### Concurrency
345+
## Concurrency
346346

347347
Asynchronous threads are created by preceding an instruction with a
348348
label with the prefix **\_\_CPROVER\_ASYNC\_**.

doc/cprover-manual/cbmc-assertions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[CPROVER Manual TOC](../../)
22

3-
### Assertion Checking
3+
## Assertion Checking
44

55
[Assertions](http://en.wikipedia.org/wiki/Assertion_%28computing%29) are
66
statements within the program that attempt to capture the programmer's

doc/cprover-manual/cbmc-tutorial.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[CPROVER Manual TOC](../../)
22

3-
### Example: Buffer Overflows
3+
## Example: Buffer Overflows
44

55
To give a brief overview of the capabilities of CBMC
66
we start with a simple example. The issue of *[buffer
@@ -30,7 +30,7 @@ lower and upper bounds, even for arrays with dynamic size. A detailed
3030
discussion of the properties that CBMC can check
3131
automatically is [here](../../properties/).
3232

33-
### First Steps
33+
## First Steps
3434

3535
We assume you have already installed CBMC and the necessary support
3636
files on your system. If not so, please follow the instructions
@@ -113,7 +113,7 @@ property for the object bounds of `argv` does not hold, and will display:
113113
[main.pointer_dereference.6] line 7 dereference failure: pointer outside object bounds in argv[(signed long int)2]: FAILURE
114114
```
115115

116-
### Counterexample Traces
116+
## Counterexample Traces
117117

118118
Let us have a closer look at this property and why it fails. To aid the
119119
understanding of the problem, CBMC can generate a *counterexample trace*
@@ -137,7 +137,7 @@ possible output format.
137137
cbmc file1.c --bounds-check --pointer-check --trace --xml-ui
138138
```
139139

140-
### Verifying Modules
140+
## Verifying Modules
141141

142142
In the example above, we used a program that starts with a `main`
143143
function. However, CBMC is aimed at embedded software, and these kinds
@@ -169,7 +169,7 @@ cbmc file2.c --function sum --bounds-check
169169
It is often necessary to build a suitable *harness* for the function in
170170
order to set up the environment appropriately.
171171

172-
### Loop Unwinding
172+
## Loop Unwinding
173173

174174
When running the previous example, you will have noted that CBMC unwinds
175175
the `for` loop in the program. As CBMC performs Bounded Model Checking,
@@ -218,7 +218,7 @@ iterations. Thus, CBMC will report that the unwinding assertion has
218218
failed. As usual, a counterexample trace that documents this can be
219219
obtained with the option `--property`.
220220

221-
### Unbounded Loops
221+
## Unbounded Loops
222222

223223
CBMC can also be used for programs with unbounded loops. In this case, CBMC
224224
is used for bug hunting only; CBMC does not attempt to find all bugs. The
@@ -293,7 +293,7 @@ but it can be helpful to find program bugs. The various command line
293293
options that CBMC offers for loop unwinding are described in the section
294294
on [understanding loop unwinding](../../cbmc/unwinding/).
295295

296-
### A Note About Compilers and the ANSI-C Library
296+
## A Note About Compilers and the ANSI-C Library
297297

298298
Most C programs make use of functions provided by a library; instances
299299
are functions from the standard ANSI-C library such as `malloc` or
@@ -307,14 +307,14 @@ requirements:
307307
Most C compilers come with header files for the ANSI C library
308308
functions. We briefly discuss how to obtain/install these library files.
309309

310-
#### Linux
310+
### Linux
311311

312312
Linux systems that are able to compile software are usually equipped
313313
with the appropriate header files. Consult the documentation of your
314314
distribution on how to install the compiler and the header files. First
315315
try to compile some significant program before attempting to verify it.
316316

317-
#### Windows
317+
### Windows
318318

319319
On Microsoft Windows, CBMC is pre-configured to use the compiler that is
320320
part of Microsoft's Visual Studio. Microsoft's [Visual Studio
@@ -331,7 +331,7 @@ comes with a small set of definitions, which includes functions such as
331331
`malloc`. Detailed information about the built-in definitions is
332332
[here](../../goto-cc/).
333333

334-
### Further Reading
334+
## Further Reading
335335

336336
- [Understanding Loop Unwinding](../../cbmc/unwinding/)
337337
- [Hardware Verification using ANSI-C Programs as a

0 commit comments

Comments
 (0)