File tree 3 files changed +19
-4
lines changed
regression/cbmc/Array_UF21
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int x [0 ] = {};
4
+ int a = x [-1 ];
5
+ x [a ] = 42 ;
6
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --arrays-uf-always --bounds-check
4
+ ^VERIFICATION FAILED$
5
+ ^EXIT=10$
6
+ ^SIGNAL=0$
7
+ --
8
+ ^warning: ignoring
9
+ ^Invariant check failed
Original file line number Diff line number Diff line change @@ -715,13 +715,13 @@ void arrayst::add_array_constraints_array_constant(
715
715
// We have a constant index - just pick the element at that index from the
716
716
// array constant.
717
717
718
- const std::size_t i =
719
- numeric_cast_v <std::size_t >(to_constant_expr (index ));
718
+ const optionalt< std::size_t > i =
719
+ numeric_cast <std::size_t >(to_constant_expr (index ));
720
720
// if the access is out of bounds, we leave it unconstrained
721
- if (i >= operands.size ())
721
+ if (!i. has_value () || * i >= operands.size ())
722
722
continue ;
723
723
724
- const exprt v = operands[i];
724
+ const exprt v = operands[* i];
725
725
DATA_INVARIANT (
726
726
index_expr.type () == v.type (),
727
727
" array operand type should match array element type" );
You can’t perform that action at this time.
0 commit comments