Skip to content

Commit 352be59

Browse files
authored
Merge pull request #6662 from tautschnig/bugfixes/5093-gen-nondet
C nondet symbol factory: arrays may have zero size
2 parents c3689cf + f507eae commit 352be59

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--function testFunc
4-
--
54
^EXIT=0$
65
^SIGNAL=0$
76
--
8-
^EXIT=134$
97
--
10-
Github issue #5093: Pointer to struct with flexible array member as parameter to entry point causes invariant violation
8+
Github issue #5093: Pointer to struct with flexible array member as parameter to
9+
entry point causes invariant violation

src/ansi-c/c_nondet_symbol_factory.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ void symbol_factoryt::gen_nondet_array_init(
172172
auto const &array_type = to_array_type(expr.type());
173173
const auto &size = array_type.size();
174174
PRECONDITION(size.id() == ID_constant);
175-
auto const array_size = numeric_cast_v<size_t>(to_constant_expr(size));
176-
DATA_INVARIANT(array_size > 0, "Arrays should have positive size");
177-
for(size_t index = 0; index < array_size; ++index)
175+
auto const array_size = numeric_cast<mp_integer>(to_constant_expr(size));
176+
DATA_INVARIANT(
177+
array_size.has_value() && *array_size >= 0,
178+
"Arrays should have positive size");
179+
for(mp_integer index = 0; index < *array_size; ++index)
178180
{
179181
gen_nondet_init(
180182
assignments,

0 commit comments

Comments
 (0)