File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -1827,13 +1827,19 @@ class struct_exprt:public exprt
1827
1827
// / \return The expression for a named component of this struct.
1828
1828
exprt &component (const irep_idt &name)
1829
1829
{
1830
- return operands ()[to_struct_type (type ()).component_number (name)];
1830
+ const auto index = to_struct_type (type ()).component_number (name);
1831
+ DATA_INVARIANT (
1832
+ index < operands ().size (), " component matching index should exist" );
1833
+ return operands ()[index ];
1831
1834
}
1832
1835
1833
1836
// / \return The expression for a named component of this struct.
1834
1837
const exprt &component (const irep_idt &name) const
1835
1838
{
1836
- return operands ()[to_struct_type (type ()).component_number (name)];
1839
+ const auto index = to_struct_type (type ()).component_number (name);
1840
+ DATA_INVARIANT (
1841
+ index < operands ().size (), " component matching index should exist" );
1842
+ return operands ()[index ];
1837
1843
}
1838
1844
};
1839
1845
You can’t perform that action at this time.
0 commit comments