Skip to content

Commit 6ffe24c

Browse files
committed
Add regression test of object size with incremental SMT solving
1 parent ef5192d commit 6ffe24c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdbool.h>
2+
#include <stddef.h>
3+
#include <stdint.h>
4+
5+
int main()
6+
{
7+
uint16_t x;
8+
uint32_t y;
9+
bool nondet_bool1;
10+
void *ptr = nondet_bool1 ? (&x) : (&y);
11+
size_t size = __CPROVER_OBJECT_SIZE(ptr);
12+
__CPROVER_assert(size == 2 || size == 4, "Expected int sizes.");
13+
__CPROVER_assert(size == 2, "Size is always 2. (Can be disproved.)");
14+
__CPROVER_assert(size == 4, "Size is always 4. (Can be disproved.)");
15+
size_t null_size = __CPROVER_OBJECT_SIZE(NULL);
16+
__CPROVER_assert(null_size == 254, "Size of NULL.");
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
object_size.c
3+
--trace
4+
line 12 Expected int sizes\.: SUCCESS
5+
line 13 Size is always 2\. \(Can be disproved\.\): FAILURE
6+
line 14 Size is always 4\. \(Can be disproved\.\): FAILURE
7+
line 16 Size of NULL\.: FAILURE
8+
size=2ul
9+
size=4ul
10+
null_size=0ul
11+
^EXIT=10$
12+
^SIGNAL=0$
13+
--
14+
--
15+
Test that the model of object_size can take only the expected values in the case
16+
where the pointer it is given may point to one of two objects. Test that the
17+
size of the null object is zero.

0 commit comments

Comments
 (0)