Skip to content

Commit 9deb9dd

Browse files
committed
Check 1st arg to points_to_valid_memory is pointer
This commit ensures that the first argument to the __CPROVER_points_to_valid_memory directive is a pointer, and adds a test to check for the failing case.
1 parent 8cf8e62 commit 9deb9dd

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main()
2+
{
3+
int r;
4+
__CPROVER_points_to_valid_memory(r, 2);
5+
}
5.81 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--apply-code-contracts
4+
^EXIT=1$
5+
^SIGNAL=0$
6+
^main.c:\d+:\d+: error: first argument to points_to_valid_memory must be a pointer$
7+
^CONVERSION ERROR$
8+
--
9+
--

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,13 @@ exprt c_typecheck_baset::do_special_functions(
21262126
<< " must be an lvalue" << eom;
21272127
throw 0;
21282128
}
2129+
if(expr.arguments()[0].type().id() != ID_pointer)
2130+
{
2131+
error().source_location = f_op.source_location();
2132+
error() << "first argument to points_to_valid_memory must be a pointer"
2133+
<< eom;
2134+
throw 0;
2135+
}
21292136

21302137
exprt same_object_expr;
21312138
if(expr.arguments().size() == 2)

0 commit comments

Comments
 (0)