Skip to content

Commit 5ce002d

Browse files
committed
Stop assertion size-of-expr for pointer-checks
Since these can be void-pointers. In this case we simply skip introducing the address-check altogether.
1 parent 1edf4d9 commit 5ce002d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <assert.h>
2+
3+
void foo(void *arg)
4+
{
5+
assert(*(unsigned *)(arg) == 5);
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--function foo --pointer-check
4+
^\[foo.assertion.1\] line \d+ assertion \*\(unsigned \*\)\(arg\) == 5: FAILURE$
5+
^\[foo.pointer_dereference.4\] line \d+ dereference failure: dead object in \*\(\(unsigned int \*\)arg\): FAILURE$
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,8 @@ void goto_checkt::pointer_validity_check(
11131113
const exprt &pointer=expr.pointer();
11141114

11151115
auto size_of_expr_opt = size_of_expr(expr.type(), ns);
1116-
CHECK_RETURN(size_of_expr_opt.has_value());
1116+
if(!size_of_expr_opt.has_value())
1117+
return; // in the case of `void*`
11171118

11181119
auto conditions = address_check(pointer, size_of_expr_opt.value());
11191120

0 commit comments

Comments
 (0)