@@ -297,16 +297,11 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
297
297
exprt size=simplify_expr (get (size_expr), ns);
298
298
299
299
// get the numeric value, unless it's infinity
300
- mp_integer size_mpint = 0 ;
300
+ const auto size_opt = numeric_cast<mp_integer>(size) ;
301
301
302
- if (size.is_not_nil () && size.id () != ID_infinity)
303
- {
304
- const auto size_opt = numeric_cast<mp_integer>(size);
305
- if (size_opt.has_value () && *size_opt >= 0 )
306
- size_mpint = *size_opt;
307
- }
308
-
309
- // search array indices
302
+ // search array indices, and only use those applicable to a particular model
303
+ // (array theory may have seen other indices, which might only be live under a
304
+ // different model)
310
305
311
306
typedef std::map<mp_integer, exprt> valuest;
312
307
valuest values;
@@ -336,7 +331,9 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
336
331
{
337
332
const auto index_mpint = numeric_cast<mp_integer>(index_value);
338
333
339
- if (index_mpint.has_value ())
334
+ if (
335
+ index_mpint.has_value () && *index_mpint >= 0 &&
336
+ (!size_opt.has_value () || *index_mpint < *size_opt))
340
337
{
341
338
if (value.is_nil ())
342
339
values[*index_mpint] =
@@ -350,7 +347,7 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
350
347
351
348
exprt result;
352
349
353
- if (values.size () != size_mpint )
350
+ if (!size_opt. has_value () || values.size () != *size_opt )
354
351
{
355
352
result = array_list_exprt ({}, to_array_type (type));
356
353
@@ -370,17 +367,18 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
370
367
result=exprt (ID_array, type);
371
368
372
369
// allocate operands
373
- std::size_t size_int = numeric_cast_v<std::size_t >(size_mpint );
370
+ std::size_t size_int = numeric_cast_v<std::size_t >(*size_opt );
374
371
result.operands ().resize (size_int, exprt{ID_unknown});
375
372
376
373
// search uninterpreted functions
377
374
378
375
for (valuest::iterator it=values.begin ();
379
376
it!=values.end ();
380
377
it++)
381
- if (it->first >=0 && it->first <size_mpint)
382
- result.operands ()[numeric_cast_v<std::size_t >(it->first )].swap (
383
- it->second );
378
+ {
379
+ result.operands ()[numeric_cast_v<std::size_t >(it->first )].swap (
380
+ it->second );
381
+ }
384
382
}
385
383
386
384
return result;
0 commit comments