Skip to content

Commit 1447ad6

Browse files
Make goto_programt::instructiont::validate() accept incomplete array types
1 parent f6dc117 commit 1447ad6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/goto-programs/goto_program.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,24 @@ void goto_programt::instructiont::validate(
728728
ns);
729729
}
730730

731+
if(
732+
!symbol_expr_type_matches_symbol_table &&
733+
goto_symbol_expr.type().id() == ID_array &&
734+
to_array_type(goto_symbol_expr.type()).is_incomplete())
735+
{
736+
// If the symbol expr has an incomplete array type, it may not have
737+
// a constant size value, whereas the symbol table entry may have
738+
// an (assumed) constant size of 1 (which mimics gcc behaviour)
739+
if(table_symbol->type.id() == ID_array)
740+
{
741+
auto symbol_table_array_type = to_array_type(table_symbol->type);
742+
symbol_table_array_type.size() = nil_exprt();
743+
744+
symbol_expr_type_matches_symbol_table = base_type_eq(
745+
goto_symbol_expr.type(), symbol_table_array_type, ns);
746+
}
747+
}
748+
731749
DATA_CHECK_WITH_DIAGNOSTICS(
732750
vm,
733751
symbol_expr_type_matches_symbol_table,

0 commit comments

Comments
 (0)