@@ -225,26 +225,35 @@ abstract_object_pointert constant_array_abstract_objectt::read_index(
225225 const index_exprt &index,
226226 const namespacet &ns) const
227227{
228- mp_integer index_value;
229- if (eval_index (index, env, ns, index_value))
228+ if (is_top ())
230229 {
231- // Here we are assuming it is always in bounds
232- if (map.find (index_value)==map.cend ())
230+ return env.abstract_object_factory (
231+ index.type (), ns, true );
232+ }
233+ else
234+ {
235+ assert (!is_bottom ());
236+ mp_integer index_value;
237+ if (eval_index (index, env, ns, index_value))
233238 {
234- return env.abstract_object_factory (type ().subtype (), ns, true , false );
239+ // Here we are assuming it is always in bounds
240+ if (map.find (index_value)==map.cend ())
241+ {
242+ return env.abstract_object_factory (type ().subtype (), ns, true , false );
243+ }
244+ else
245+ {
246+ return map.find (index_value)->second ;
247+ }
235248 }
236249 else
237250 {
238- return map.find (index_value)->second ;
251+ // Reading from somewhere in the array
252+ // TODO(tkiley): merge all the values of the array, we may be able to
253+ // do better than returning top
254+ return env.abstract_object_factory (type ().subtype (), ns, true , false );
239255 }
240256 }
241- else
242- {
243- // Reading from somewhere in the array
244- // TODO(tkiley): merge all the values of the array, we may be able to
245- // do better than returning top
246- return env.abstract_object_factory (type ().subtype (), ns, true , false );
247- }
248257}
249258
250259/* ******************************************************************\
0 commit comments