File tree 6 files changed +80
-0
lines changed
regression/cbmc-primitives 6 files changed +80
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include <assert.h>
2
2
#include <stdlib.h>
3
3
4
+ // clang-format off
4
5
int main () {
5
6
char * a = malloc (1 );
6
7
@@ -14,3 +15,4 @@ int main() {
14
15
}
15
16
);
16
17
}
18
+ // clang-format on
Original file line number Diff line number Diff line change 1
1
#include <assert.h>
2
2
#include <stdlib.h>
3
3
4
+ // clang-format off
4
5
int main () {
5
6
char * a = malloc (128 );
6
7
@@ -15,3 +16,4 @@ int main() {
15
16
int j ; !(0 <= j && j < 1 ) || (j == 0 && * (a + j ) == * (a + j ))
16
17
});
17
18
}
19
+ // clang-format on
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ // This is essentially the same file as in test `forall_6231_1`, with the difference
5
+ // being that the forall statement contains a bigger bound, so that we are to have
6
+ // more concrete instantiations of the bound variable.
7
+
8
+ // clang-format off
9
+ int main () {
10
+ char * a = malloc (10 );
11
+
12
+ // lots of errors with `--pointer-check` enabled
13
+ assert (* a == * a );
14
+
15
+ // no errors even with `--pointer-check` enabled
16
+ assert (
17
+ __CPROVER_forall {
18
+ int i ; (0 <= i && i < 10 ) == > * (a + i ) == * (a + i )
19
+ }
20
+ );
21
+ }
22
+ // clang-format on
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ \[main\.assertion\.2\] line \d+ assertion __CPROVER_forall \{ int i ; \(0 <= i && i < 10\) ==> \*\(a\+i\) == \*\(a\+i\) \}: SUCCESS
7
+ \[main\.pointer_dereference\.7\] line \d+ dereference failure: pointer NULL in a\[\(signed long int\)i\]: SUCCESS
8
+ \[main\.pointer_dereference\.8\] line \d+ dereference failure: pointer invalid in a\[\(signed long int\)i\]: SUCCESS
9
+ \[main\.pointer_dereference\.9\] line \d+ dereference failure: deallocated dynamic object in a\[\(signed long int\)i\]: SUCCESS
10
+ \[main\.pointer_dereference\.10\] line \d+ dereference failure: dead object in a\[\(signed long int\)i\]: SUCCESS
11
+ \[main\.pointer_dereference\.11\] line \d+ dereference failure: pointer outside object bounds in a\[\(signed long int\)i\]: SUCCESS
12
+ \[main\.pointer_dereference\.12\] line \d+ dereference failure: invalid integer address in a\[\(signed long int\)i\]: SUCCESS
13
+ ^VERIFICATION SUCCESSFUL$
14
+ --
15
+ --
16
+ This is fixing an issue first reported in https://github.com/diffblue/cbmc/issues/6231
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ // Similar to our test in `test.c` of this folder, with the difference being
5
+ // that the malloc size is less than the bound checked, which implies that the
6
+ // check for the pointer being outside the object bounds is expected to fail.
7
+
8
+ // clang-format off
9
+ int main () {
10
+ char * a = malloc (4 );
11
+
12
+ // lots of errors with `--pointer-check` enabled
13
+ assert (* a == * a );
14
+
15
+ // no errors even with `--pointer-check` enabled
16
+ assert (
17
+ __CPROVER_forall {
18
+ int i ; (0 <= i && i < 10 ) == > * (a + i ) == * (a + i )
19
+ }
20
+ );
21
+ }
22
+ // clang-format on
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test_malloc_less_than_bound.c
3
+ --pointer-check
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ \[main\.assertion\.2\] line \d+ assertion __CPROVER_forall \{ int i ; \(0 <= i && i < 10\) ==> \*\(a\+i\) == \*\(a\+i\) \}: SUCCESS
7
+ \[main\.pointer_dereference\.7\] line \d+ dereference failure: pointer NULL in a\[\(signed long int\)i\]: SUCCESS
8
+ \[main\.pointer_dereference\.8\] line \d+ dereference failure: pointer invalid in a\[\(signed long int\)i\]: SUCCESS
9
+ \[main\.pointer_dereference\.9\] line \d+ dereference failure: deallocated dynamic object in a\[\(signed long int\)i\]: SUCCESS
10
+ \[main\.pointer_dereference\.10\] line \d+ dereference failure: dead object in a\[\(signed long int\)i\]: SUCCESS
11
+ \[main\.pointer_dereference\.11\] line \d+ dereference failure: pointer outside object bounds in a\[\(signed long int\)i\]: FAILURE
12
+ \[main\.pointer_dereference\.12\] line \d+ dereference failure: invalid integer address in a\[\(signed long int\)i\]: SUCCESS
13
+ ^VERIFICATION FAILED$
14
+ --
15
+ --
16
+ This is fixing an issue first reported in https://github.com/diffblue/cbmc/issues/6231
You can’t perform that action at this time.
0 commit comments