Skip to content

Commit 513aa97

Browse files
committed
Visual Studio rejects pointer arithmetic and dereferencing of void*
Pointer arithmetic using void* is a (document) GCC extension. Dereferencing void* pointers is permitted by GCC when the value is unused. Visual Studio rejects both. This required updates to tests to either not rely on pointer arithmetic over void*, or restrict tests to GCC only. Fixes: #5275
1 parent 12ef9e7 commit 513aa97

File tree

14 files changed

+76
-8
lines changed

14 files changed

+76
-8
lines changed

regression/cbmc/null6/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void *guard_malloc_counter = 0;
1+
char *guard_malloc_counter = 0;
22

33
void *my_malloc(int size)
44
{

regression/cbmc/ptr_arithmetic_on_null/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE gcc-only
22
main.c
33

44
^\[main.assertion.1\] line .* assertion \(void \*\)0 != \(void \*\)0 \+ \(.*\)1: SUCCESS$

regression/cbmc/void_pointer1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE gcc-only
22
main.c
33
--pointer-check
44
^EXIT=0$

regression/cbmc/void_pointer2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE gcc-only
22
main.c
33
--pointer-check --no-simplify --unwind 3
44
^EXIT=0$

regression/cbmc/void_pointer3/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE broken-smt-backend
1+
CORE broken-smt-backend gcc-only
22
main.c
33

44
^EXIT=0$

regression/cbmc/void_pointer5/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE broken-smt-backend
1+
CORE broken-smt-backend gcc-only
22
main.c
33

44
^EXIT=10$

regression/cbmc/void_pointer6/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE gcc-only
22
main.c
33
--pointer-check
44
^EXIT=10$

regression/cbmc/void_pointer7/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
CORE gcc-only
22
main.c
33
--pointer-check
44
^EXIT=0$
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
void *malloc(__CPROVER_size_t);
2+
int printf(const char *, ...);
3+
4+
int main(int argc, char *argv[])
5+
{
6+
void *p = malloc(2);
7+
printf("%p\n", p);
8+
#ifdef VOID1
9+
(void)*p;
10+
#else
11+
void *q = &p[1];
12+
printf("%p\n", q);
13+
#endif
14+
return 0;
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
4+
error: pointer arithmetic with unknown object size
5+
^CONVERSION ERROR$
6+
^EXIT=(64|1)$
7+
^SIGNAL=0$
8+
--
9+
Invariant check failed

0 commit comments

Comments
 (0)