manual; try to clarify better how variable contracts are used by cppcheck

This commit is contained in:
Daniel Marjamäki 2020-08-28 19:42:52 +02:00
parent 18c29544eb
commit acd1e848dd
1 changed files with 7 additions and 0 deletions

View File

@ -995,6 +995,13 @@ Here is an example code:
The bug hunting analysis will warn about a division by zero. It can't be proven The bug hunting analysis will warn about a division by zero. It can't be proven
that x can't be 0. that x can't be 0.
A variable contract specify the allowed values for a variable. Cppcheck use variable
contracts both when a variable is read and written:
- When a variable is read, Cppcheck will assume that the contract is met. This
means you can avoid false positives for impossible variable values.
- When a variable is written, Cppcheck will ensure that its contract is not
violated. If it can't be determined that the contract is met you will get a
warning.
#### Annotation #### Annotation