@@ -1166,6 +1166,7 @@ void __CPROVER_contracts_make_invalid_pointer(void **ptr)
11661166///
11671167/// \param ptr1 First argument of the `pointer_equals` predicate
11681168/// \param ptr2 Second argument of the `pointer_equals` predicate
1169+ /// \param may_fail Allow predicate to fail in assume mode
11691170/// \param write_set Write set which conveys the invocation context
11701171/// (requires/ensures clause, assert/assume context);
11711172///
@@ -1179,6 +1180,7 @@ void __CPROVER_contracts_make_invalid_pointer(void **ptr)
11791180__CPROVER_bool __CPROVER_contracts_pointer_equals (
11801181 void * * ptr1 ,
11811182 void * ptr2 ,
1183+ __CPROVER_bool may_fail ,
11821184 __CPROVER_contracts_write_set_ptr_t write_set )
11831185{
11841186__CPROVER_HIDE :;
@@ -1195,7 +1197,8 @@ __CPROVER_HIDE:;
11951197#endif
11961198 if (write_set -> assume_requires_ctx | write_set -> assume_ensures_ctx )
11971199 {
1198- if (__VERIFIER_nondet___CPROVER_bool ())
1200+ // SOUNDNESS: allow predicate to fail
1201+ if (may_fail && __VERIFIER_nondet___CPROVER_bool ())
11991202 {
12001203 __CPROVER_contracts_make_invalid_pointer (ptr1 );
12011204 return 0 ;
@@ -1224,8 +1227,9 @@ __CPROVER_HIDE:;
12241227/// The behaviour depends on the boolean flags carried by \p write_set
12251228/// which reflect the invocation context: checking vs. replacing a contract,
12261229/// in a requires or an ensures clause context.
1227- /// \param elem First argument of the `is_fresh` predicate
1228- /// \param size Second argument of the `is_fresh` predicate
1230+ /// \param elem Pointer to the target pointer of the check
1231+ /// \param size Size to check for
1232+ /// \param may_fail Allow predicate to fail in assume mode
12291233/// \param write_set Write set in which seen/allocated objects are recorded;
12301234///
12311235/// \details The behaviour is as follows:
@@ -1242,6 +1246,7 @@ __CPROVER_HIDE:;
12421246__CPROVER_bool __CPROVER_contracts_is_fresh (
12431247 void * * elem ,
12441248 __CPROVER_size_t size ,
1249+ __CPROVER_bool may_fail ,
12451250 __CPROVER_contracts_write_set_ptr_t write_set )
12461251{
12471252__CPROVER_HIDE :;
@@ -1289,7 +1294,7 @@ __CPROVER_HIDE:;
12891294 }
12901295
12911296 // SOUNDNESS: allow predicate to fail
1292- if (__VERIFIER_nondet___CPROVER_bool ())
1297+ if (may_fail && __VERIFIER_nondet___CPROVER_bool ())
12931298 {
12941299 __CPROVER_contracts_make_invalid_pointer (elem );
12951300 return 0 ;
@@ -1349,7 +1354,7 @@ __CPROVER_HIDE:;
13491354 }
13501355
13511356 // SOUNDNESS: allow predicate to fail
1352- if (__VERIFIER_nondet___CPROVER_bool ())
1357+ if (may_fail && __VERIFIER_nondet___CPROVER_bool ())
13531358 {
13541359 __CPROVER_contracts_make_invalid_pointer (elem );
13551360 return 0 ;
@@ -1436,6 +1441,7 @@ __CPROVER_HIDE:;
14361441/// \param lb Lower bound pointer
14371442/// \param ptr Target pointer of the predicate
14381443/// \param ub Upper bound pointer
1444+ /// \param may_fail Allow predicate to fail in assume mode
14391445/// \param write_set Write set in which seen/allocated objects are recorded;
14401446///
14411447/// \details The behaviour is as follows:
@@ -1449,6 +1455,7 @@ __CPROVER_bool __CPROVER_contracts_pointer_in_range_dfcc(
14491455 void * lb ,
14501456 void * * ptr ,
14511457 void * ub ,
1458+ __CPROVER_bool may_fail ,
14521459 __CPROVER_contracts_write_set_ptr_t write_set )
14531460{
14541461__CPROVER_HIDE :;
@@ -1470,9 +1477,9 @@ __CPROVER_HIDE:;
14701477 lb_offset <= ub_offset , "lb and ub pointers must be ordered" );
14711478 if (write_set -> assume_requires_ctx | write_set -> assume_ensures_ctx )
14721479 {
1473- if (__VERIFIER_nondet___CPROVER_bool ())
1480+ // SOUNDNESS: allow predicate to fail
1481+ if (may_fail && __VERIFIER_nondet___CPROVER_bool ())
14741482 {
1475- // SOUNDNESS: allow predicate to fail
14761483 __CPROVER_contracts_make_invalid_pointer (ptr );
14771484 return 0 ;
14781485 }
@@ -1647,6 +1654,7 @@ __CPROVER_HIDE:;
16471654__CPROVER_bool __CPROVER_contracts_obeys_contract (
16481655 void (* * function_pointer )(void ),
16491656 void (* contract )(void ),
1657+ __CPROVER_bool may_fail ,
16501658 __CPROVER_contracts_write_set_ptr_t set )
16511659{
16521660__CPROVER_HIDE :;
@@ -1657,8 +1665,8 @@ __CPROVER_HIDE:;
16571665 "__CPROVER_obeys_contract is used only in requires or ensures clauses" );
16581666 if ((set -> assume_requires_ctx == 1 ) | (set -> assume_ensures_ctx == 1 ))
16591667 {
1660- // decide if predicate must hold
1661- if (__VERIFIER_nondet___CPROVER_bool ())
1668+ // SOUDNESS: allow predicate to fail
1669+ if (may_fail && __VERIFIER_nondet___CPROVER_bool ())
16621670 return 0 ;
16631671
16641672 // must hold, assign the function pointer to the contract function
0 commit comments