Skip to content

Commit 9bb422d

Browse files
authored
Merge pull request #7371 from tautschnig/bugfixes/c-lib-contracts
C library: Fix type inconsistencies in contracts code
2 parents 1453345 + 4dc64e2 commit 9bb422d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/ansi-c/library/cprover_contracts.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
// external dependencies
1010
extern __CPROVER_size_t __CPROVER_max_malloc_size;
11-
extern void *__CPROVER_alloca_object;
11+
extern const void *__CPROVER_alloca_object;
1212
extern const void *__CPROVER_deallocated;
1313
extern const void *__CPROVER_new_object;
1414
extern __CPROVER_bool __CPROVER_malloc_is_new_array;
1515
int __builtin_clzll(unsigned long long);
16-
char __VERIFIER_nondet_char();
1716
__CPROVER_bool __VERIFIER_nondet_CPROVER_bool();
1817

1918
/// \brief A conditionally writable range of bytes.
@@ -245,8 +244,8 @@ __CPROVER_HIDE:;
245244
// symex state from the number of object_bits/offset_bits
246245
// the number of object bits is determined by counting the number of leading
247246
// zeroes of the built-in constant __CPROVER_max_malloc_size;
248-
__CPROVER_size_t object_bits = __builtin_clzll(__CPROVER_max_malloc_size);
249-
__CPROVER_size_t nof_objects = 1UL << object_bits;
247+
int object_bits = __builtin_clzll(__CPROVER_max_malloc_size);
248+
__CPROVER_size_t nof_objects = 1ULL << object_bits;
250249
*set = (__CPROVER_contracts_obj_set_t){
251250
.max_elems = nof_objects,
252251
.watermark = 0,
@@ -1143,7 +1142,6 @@ void *__CPROVER_contracts_malloc(
11431142
__CPROVER_size_t,
11441143
__CPROVER_contracts_write_set_ptr_t);
11451144

1146-
__CPROVER_bool __VERIFIER_nondet_bool();
11471145
/// \brief Implementation of the `is_fresh` front-end predicate.
11481146
///
11491147
/// The behaviour depends on the boolean flags carried by \p set
@@ -1170,7 +1168,7 @@ __CPROVER_bool __CPROVER_contracts_is_fresh(
11701168
__CPROVER_contracts_write_set_ptr_t write_set)
11711169
{
11721170
if(!write_set)
1173-
return __VERIFIER_nondet_bool();
1171+
return __VERIFIER_nondet_CPROVER_bool();
11741172
__CPROVER_HIDE:;
11751173
#ifdef DFCC_DEBUG
11761174
__CPROVER_assert(

src/cpp/library/cprover.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ typedef __typeof__(sizeof(int)) __CPROVER_size_t;
1414
void *__CPROVER_allocate(__CPROVER_size_t size, __CPROVER_bool zero);
1515
extern const void *__CPROVER_deallocated;
1616
extern const void *__CPROVER_new_object;
17-
extern _Bool __CPROVER_malloc_is_new_array;
17+
extern __CPROVER_bool __CPROVER_malloc_is_new_array;
1818
extern const void *__CPROVER_memory_leak;
1919

2020
void __CPROVER_assume(__CPROVER_bool assumption) __attribute__((__noreturn__));

0 commit comments

Comments
 (0)