Skip to content

Commit e8ac4d6

Browse files
committed
bits2expr: create union expressions when components aren't full width
A union_exprt can refer to components of a type that is smaller than the full bit width of the union. Consequently, bits2expr should accept bit strings for such (smaller) members.
1 parent 9a51a92 commit e8ac4d6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/util/simplify_utils.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,15 @@ optionalt<exprt> bits2expr(
185185
// bits start at lowest memory address
186186
auto type_bits = pointer_offset_bits(type, ns);
187187

188-
if(!type_bits.has_value() || *type_bits != bits.size())
188+
if(
189+
!type_bits.has_value() ||
190+
(type.id() != ID_union && type.id() != ID_union_tag &&
191+
*type_bits != bits.size()) ||
192+
((type.id() == ID_union || type.id() == ID_union_tag) &&
193+
*type_bits < bits.size()))
194+
{
189195
return {};
196+
}
190197

191198
if(
192199
type.id() == ID_unsignedbv || type.id() == ID_signedbv ||

0 commit comments

Comments
 (0)