Skip to content

C nondet symbol factory: arrays may have zero size #6662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
KNOWNBUG
CORE
main.c
--function testFunc
--
^EXIT=0$
^SIGNAL=0$
--
^EXIT=134$
--
Github issue #5093: Pointer to struct with flexible array member as parameter to entry point causes invariant violation
Github issue #5093: Pointer to struct with flexible array member as parameter to
entry point causes invariant violation
8 changes: 5 additions & 3 deletions src/ansi-c/c_nondet_symbol_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ void symbol_factoryt::gen_nondet_array_init(
auto const &array_type = to_array_type(expr.type());
const auto &size = array_type.size();
PRECONDITION(size.id() == ID_constant);
auto const array_size = numeric_cast_v<size_t>(to_constant_expr(size));
DATA_INVARIANT(array_size > 0, "Arrays should have positive size");
for(size_t index = 0; index < array_size; ++index)
auto const array_size = numeric_cast<mp_integer>(to_constant_expr(size));
DATA_INVARIANT(
array_size.has_value() && *array_size >= 0,
"Arrays should have positive size");
for(mp_integer index = 0; index < *array_size; ++index)
{
gen_nondet_init(
assignments,
Expand Down