@@ -98,7 +98,8 @@ static struct_exprt bv_to_struct_expr(
9898
9999 if (component_bits == 0 )
100100 {
101- operands.push_back (constant_exprt{irep_idt{}, comp.type ()});
101+ operands.push_back (
102+ bv_to_expr (bitvector_expr, comp.type (), endianness_map, ns));
102103 continue ;
103104 }
104105
@@ -123,17 +124,16 @@ static struct_exprt bv_to_struct_expr(
123124
124125// / Convert a bitvector-typed expression \p bitvector_expr to a union-typed
125126// / expression. See \ref bv_to_expr for an overview.
126- static union_exprt bv_to_union_expr (
127+ static exprt bv_to_union_expr (
127128 const exprt &bitvector_expr,
128129 const union_typet &union_type,
129130 const endianness_mapt &endianness_map,
130131 const namespacet &ns)
131132{
132133 const union_typet::componentst &components = union_type.components ();
133134
134- // empty union, handled the same way as done in expr_initializert
135135 if (components.empty ())
136- return union_exprt{irep_idt{}, nil_exprt{}, union_type};
136+ return empty_union_exprt{ union_type};
137137
138138 const auto widest_member = union_type.find_widest_union_component (ns);
139139
@@ -147,7 +147,7 @@ static union_exprt bv_to_union_expr(
147147 {
148148 return union_exprt{
149149 components.front ().get_name (),
150- constant_exprt{irep_idt{} , components.front ().type ()} ,
150+ bv_to_expr (bitvector_expr , components.front ().type (), endianness_map, ns) ,
151151 union_type};
152152 }
153153
@@ -371,13 +371,13 @@ static exprt bv_to_expr(
371371 }
372372 else if (target_type.id () == ID_union_tag)
373373 {
374- union_exprt result = bv_to_union_expr (
374+ exprt result = bv_to_union_expr (
375375 bitvector_expr,
376376 ns.follow_tag (to_union_tag_type (target_type)),
377377 endianness_map,
378378 ns);
379379 result.type () = target_type;
380- return std::move ( result) ;
380+ return result;
381381 }
382382 else if (target_type.id () == ID_array)
383383 {
0 commit comments