Skip to content

Commit 2d8ab18

Browse files
author
Remi Delmas
committed
In failure cases for is_fresh, create nondet pointer to null or unique empty object.
Removes nondeterminism on the pointer offset but solves performance problem with quantifiers.
1 parent f8448a6 commit 2d8ab18

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/ansi-c/library/cprover_contracts.c

+30-9
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,16 @@ __CPROVER_HIDE:;
12061206
}
12071207
if(__VERIFIER_nondet___CPROVER_bool())
12081208
{
1209-
// make pointer invalid, empty value set and nondet bit pattern
1210-
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
1211-
*elem = (void *)dummy;
1209+
// in the failure case, make pointer null or pointing to a unique
1210+
// dummy object of size 0.
1211+
if(__VERIFIER_nondet___CPROVER_bool())
1212+
{
1213+
*elem = (void *)0;
1214+
}
1215+
else
1216+
{
1217+
*elem = __CPROVER_allocate(0, 0);
1218+
}
12121219
return 0;
12131220
}
12141221
void *ptr = __CPROVER_allocate(size, 0);
@@ -1266,9 +1273,16 @@ __CPROVER_HIDE:;
12661273
}
12671274
if(__VERIFIER_nondet___CPROVER_bool())
12681275
{
1269-
// make pointer invalid, empty value set and nondet bit pattern
1270-
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
1271-
*elem = (void *)dummy;
1276+
// in the failure case, make pointer null or pointing to a unique
1277+
// dummy object of size 0.
1278+
if(__VERIFIER_nondet___CPROVER_bool())
1279+
{
1280+
*elem = (void *)0;
1281+
}
1282+
else
1283+
{
1284+
*elem = __CPROVER_allocate(0, 0);
1285+
}
12721286
return 0;
12731287
}
12741288
void *ptr = __CPROVER_allocate(size, 0);
@@ -1372,9 +1386,16 @@ __CPROVER_HIDE:;
13721386
{
13731387
if(__VERIFIER_nondet___CPROVER_bool())
13741388
{
1375-
// make pointer invalid, empty value set and nondet bit pattern
1376-
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
1377-
*ptr = (void *)dummy;
1389+
// in the failure case, make pointer null or pointing to a unique
1390+
// dummy object of size 0.
1391+
if(__VERIFIER_nondet___CPROVER_bool())
1392+
{
1393+
*ptr = (void *)0;
1394+
}
1395+
else
1396+
{
1397+
*ptr = __CPROVER_allocate(0, 0);
1398+
}
13781399
return 0;
13791400
}
13801401

0 commit comments

Comments
 (0)