Skip to content

Commit a49e636

Browse files
author
Thomas Kiley
authored
Merge pull request #5408 from thomasspriggs/tas/fix-array-types
Fix type mismatch in goto-harness on calling array constructor.
2 parents 1f1de48 + 122afe8 commit a49e636

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void test(signed int *arr)
2+
{
3+
arr[0l] = 5;
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
example.c
3+
--harness-type call-function --function test --treat-pointer-as-array arr
4+
VERIFICATION SUCCESSFUL
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
type_constructor_ptr_int\(0, &arr, \(signed int \*\)\(void \*\)0\);
8+
--
9+
incompatible pointer types
10+
--
11+
Ensure that the function pointer types match

src/goto-harness/recursive_initialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ void recursive_initializationt::initialize(
209209
{
210210
const auto &fun_type_params =
211211
to_code_type(fun_symbol.type).parameters();
212-
const typet &size_var_type = fun_type_params.back().type();
212+
const pointer_typet *size_var_type =
213+
type_try_dynamic_cast<pointer_typet>(fun_type_params.back().type());
214+
INVARIANT(size_var_type, "Size parameter must have pointer type.");
213215
body.add(code_function_callt{
214216
fun_symbol.symbol_expr(),
215-
{depth,
216-
address_of_exprt{lhs},
217-
null_pointer_exprt{pointer_type(size_var_type)}}});
217+
{depth, address_of_exprt{lhs}, null_pointer_exprt{*size_var_type}}});
218218
}
219219
return;
220220
}

0 commit comments

Comments
 (0)