Skip to content

Commit dd77754

Browse files
authored
Merge pull request #6212 from NlightNFotis/add_5952_tests
Include tests from reported issue cbmc#5952.
2 parents 403a129 + e409ce2 commit dd77754

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
#include <stdbool.h>
3+
#include <stdlib.h>
4+
5+
bool validate(const char *data, unsigned allocated)
6+
{
7+
// clang-format off
8+
bool check_1 = (data == NULL ==> allocated == 0);
9+
bool check_2 = (allocated != 0 ==> __CPROVER_r_ok(data, allocated));
10+
// clang-format on
11+
return check_1 && check_2;
12+
}
13+
14+
void main()
15+
{
16+
char *data;
17+
unsigned allocated;
18+
19+
data = (allocated == 0) ? NULL : malloc(allocated);
20+
21+
__CPROVER_assume(validate(data, allocated));
22+
23+
assert(validate(data, allocated));
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
void main()
5+
{
6+
char *data;
7+
data = nondet() ? malloc(1) : malloc(2);
8+
assert(__CPROVER_OBJECT_SIZE(data) <= 2);
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG broken-smt-backend
2+
original_repro.c
3+
--smt2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
\[main.assertion.\d\] line \d+ assertion validate\(data, allocated\): SUCCESS
8+
--
9+
\[main.assertion.\d\] line \d+ assertion validate\(data, allocated\): FAILURE
10+
--
11+
This is the original code that demonstrates the issue described in
12+
https://github.com/diffblue/cbmc/issues/5952
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
short.c
3+
--smt2
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
\[main.assertion.\d\] line \d assertion __CPROVER_OBJECT_SIZE\(data\) <= 2: SUCCESS
8+
--
9+
\[main.assertion.\d\] line \d assertion __CPROVER_OBJECT_SIZE\(data\) <= 2: FAILURE
10+
--
11+
This is the reduced version of the issue described in
12+
https://github.com/diffblue/cbmc/issues/5952

0 commit comments

Comments
 (0)