You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/cprover-manual/properties.md
+39-15Lines changed: 39 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -134,40 +134,64 @@ As all of these checks apply across the entire input program, we may wish to
134
134
disable them for selected statements in the program. For example, unsigned
135
135
overflows can be expected and acceptable in certain instructions even when
136
136
elsewhere we do not expect them. As of version 5.12, CBMC supports selectively
137
-
disabling or enabling automatically generated properties.
137
+
disabling or enabling automatically generated properties using pragmas.
138
138
139
-
To disable property generation,
140
-
use `#pragma CPROVER check disable "<name_of_check>"`, which remains in effect
141
-
until a `#pragma CPROVER check pop` (to re-enable all properties
142
-
disabled or enabled before or since the last `#pragma CPROVER check push`) is provided.
139
+
140
+
CPROVER pragmas are handled using a stack:
141
+
- `#pragma CPROVER check push` pushes a new level on the pragma stack
142
+
- `#pragma CPROVER check disable "<name_of_check>"` adds a disable pragma at the top of the stack
143
+
- `#pragma CPROVER check enable "<name_of_check>"` adds a enable pragma at the top of the stack
144
+
- an `enable` or `disable` pragma for a given check present at the top level of the stack shadows other pragmas for the same in lower levels of the stack
145
+
- adding both `enable` and `disable` pragmas for a same check in a same level of the stack creates a warning, the most recent pragma takes precedence
146
+
- `#pragma CPROVER check pop` pops a level in the stack and restores the state of pragmas at the sub level
143
147
144
148
For example, for unsigned overflow checks, use
149
+
145
150
```
146
151
unsigned foo(unsigned x)
147
152
{
148
153
#pragma CPROVER check push
149
-
#pragma CPROVER check disable "unsigned-overflow"
150
-
x = x + 1; // immediately follows the pragma, no unsigned overflow check here
154
+
#pragma CPROVER check enable "unsigned-overflow"
155
+
x = x + 1; // immediately follows the pragma, unsigned overflow check apply here
151
156
#pragma CPROVER check pop
152
-
x = x + 2; // unsigned overflow checks are generated here
157
+
x = x + 2; // unsigned overflow checks do not apply here
153
158
```
154
159
155
-
To enable property generation,
156
-
use `#pragma CPROVER check enable "<name_of_check>"`, which remains in effect
157
-
until a `#pragma CPROVER check pop` (to re-enable all properties
158
-
disabled or enabled before or since the last `#pragma CPROVER check push`) is provided.
160
+
```
161
+
unsigned foo(unsigned x)
162
+
{
163
+
#pragma CPROVER check push
164
+
#pragma CPROVER check enable "unsigned-overflow"
165
+
#pragma CPROVER check enable "signed-overflow"
166
+
x = x + 1; // unsigned and signed overflow check apply here
167
+
#pragma CPROVER check push
168
+
#pragma CPROVER check disable "unsigned-overflow"
169
+
x = x + 2; // only signed overflow check apply here
170
+
#pragma CPROVER check pop
171
+
x = x + 3; // unsigned and signed overflow check apply here
172
+
#pragma CPROVER check pop
173
+
x = x + 2; // unsigned overflow checks do not apply here
174
+
```
159
175
160
-
For example, for unsigned overflow checks, use
161
176
```
162
177
unsigned foo(unsigned x)
163
178
{
164
179
#pragma CPROVER check push
165
180
#pragma CPROVER check enable "unsigned-overflow"
166
-
x = x + 1; // immediately follows the pragma, unsigned overflow check are generated here
181
+
#pragma CPROVER check enable "signed-overflow"
182
+
x = x + 1; // unsigned and signed overflow check apply here
183
+
#pragma CPROVER check push
184
+
#pragma CPROVER check disable "unsigned-overflow"
185
+
#pragma CPROVER check enable "unsigned-overflow"
186
+
// warning: both enable and disable for unsigned-overflow (last one takes precedence)
187
+
x = x + 2; // unsigned and signed overflow check apply here
167
188
#pragma CPROVER check pop
168
-
x = x + 2; // unsigned overflow checks are not generated here
189
+
x = x + 3; // unsigned and signed overflow check apply here
190
+
#pragma CPROVER check pop
191
+
x = x + 2; // unsigned overflow checks do not apply here
169
192
```
170
193
194
+
171
195
#### Flag --nan-check limitations
172
196
173
197
Please note that `--nan-check` flag is adding not-a-number checks only for
0 commit comments