Skip to content

Commit 8fe2acf

Browse files
Make goto_programt::instructiont::validate() accept incomplete array types
1 parent 9061ae3 commit 8fe2acf

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
@@ -740,6 +740,24 @@ void goto_programt::instructiont::validate(
740740
}
741741
}
742742

743+
if(
744+
!symbol_expr_type_matches_symbol_table &&
745+
goto_symbol_expr.type().id() == ID_array &&
746+
to_array_type(goto_symbol_expr.type()).is_incomplete())
747+
{
748+
// If the symbol expr has an incomplete array type, it may not have
749+
// a constant size value, whereas the symbol table entry may have
750+
// an (assumed) constant size of 1 (which mimics gcc behaviour)
751+
if(table_symbol->type.id() == ID_array)
752+
{
753+
auto symbol_table_array_type = to_array_type(table_symbol->type);
754+
symbol_table_array_type.size() = nil_exprt();
755+
756+
symbol_expr_type_matches_symbol_table = base_type_eq(
757+
goto_symbol_expr.type(), symbol_table_array_type, ns);
758+
}
759+
}
760+
743761
DATA_CHECK_WITH_DIAGNOSTICS(
744762
vm,
745763
symbol_expr_type_matches_symbol_table,

0 commit comments

Comments
 (0)