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
+27-16Lines changed: 27 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -134,16 +134,21 @@ 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 using pragmas.
137
+
disabling or enabling automatically generated properties using pragmas.
138
138
139
139
140
140
CPROVER pragmas are handled using a stack:
141
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 PARSING_ERROR.
146
-
- `#pragma CPROVER check pop` pops a level in the stack and restores the state of pragmas at the sub level
142
+
- `#pragma CPROVER check disable "<name_of_check>"` adds a disable pragma
143
+
at the top of the stack
144
+
- `#pragma CPROVER check enable "<name_of_check>"` adds a enable pragma
145
+
at the top of the stack
146
+
- an `enable` or `disable` pragma for a given check present at the top level
147
+
of the stack shadows other pragmas for the same in lower levels of the stack
148
+
- adding both `enable` and `disable` pragmas for a same check in a same level
149
+
of the stack creates a PARSING_ERROR.
150
+
- `#pragma CPROVER check pop` pops a level in the stack and restores the state
151
+
of pragmas at the sub level
147
152
148
153
For example, for unsigned overflow checks, use
149
154
@@ -152,9 +157,11 @@ unsigned foo(unsigned x)
152
157
{
153
158
#pragma CPROVER check push
154
159
#pragma CPROVER check enable "unsigned-overflow"
155
-
x = x + 1; // immediately follows the pragma, unsigned overflow check apply here
160
+
// unsigned overflow check apply here
161
+
x = x + 1;
156
162
#pragma CPROVER check pop
157
-
x = x + 2; // unsigned overflow checks do not apply here
163
+
// unsigned overflow checks do not apply here
164
+
x = x + 2;
158
165
```
159
166
160
167
```
@@ -163,14 +170,18 @@ unsigned foo(unsigned x)
163
170
#pragma CPROVER check push
164
171
#pragma CPROVER check enable "unsigned-overflow"
165
172
#pragma CPROVER check enable "signed-overflow"
166
-
x = x + 1; // unsigned and signed overflow check apply here
173
+
// unsigned and signed overflow check apply here
174
+
x = x + 1;
167
175
#pragma CPROVER check push
168
176
#pragma CPROVER check disable "unsigned-overflow"
169
-
x = x + 2; // only signed overflow check apply here
177
+
// only signed overflow check apply here
178
+
x = x + 2;
170
179
#pragma CPROVER check pop
171
-
x = x + 3; // unsigned and signed overflow check apply here
180
+
// unsigned and signed overflow check apply here
181
+
x = x + 3;
172
182
#pragma CPROVER check pop
173
-
x = x + 2; // unsigned overflow checks do not apply here
183
+
// unsigned overflow checks do not apply here
184
+
x = x + 2;
174
185
```
175
186
176
187
```
@@ -179,19 +190,19 @@ unsigned foo(unsigned x)
179
190
#pragma CPROVER check push
180
191
#pragma CPROVER check enable "unsigned-overflow"
181
192
#pragma CPROVER check enable "signed-overflow"
182
-
x = x + 1; // unsigned and signed overflow check apply here
193
+
// unsigned and signed overflow check apply here
194
+
x = x + 1;
183
195
#pragma CPROVER check push
184
196
#pragma CPROVER check disable "unsigned-overflow"
185
-
#pragma CPROVER check enable "unsigned-overflow"
186
-
// PARSING_ERROR ... Found enable and disable pragmas for unsigned-overflow-check
197
+
#pragma CPROVER check enable "unsigned-overflow"
198
+
// PARSING_ERROR Found enable and disable pragmas for unsigned-overflow-check
187
199
x = x + 2;
188
200
#pragma CPROVER check pop
189
201
x = x + 3;
190
202
#pragma CPROVER check pop
191
203
x = x + 2;
192
204
```
193
205
194
-
195
206
#### Flag --nan-check limitations
196
207
197
208
Please note that `--nan-check` flag is adding not-a-number checks only for
0 commit comments