Skip to content

Commit e021eef

Browse files
committed
Support byte-extracting empty structs
Empty structs are a GCC extension, which in general we do support. Notably, boolbvt::convert_struct happily produces (empty) bitvectors for empty structs. This commit makes sure byte-extracting empty structs is equally supported.
1 parent c99dcc8 commit e021eef

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
struct empty
2+
{
3+
};
4+
5+
struct non_empty
6+
{
7+
int x;
8+
};
9+
10+
union U
11+
{
12+
struct empty e;
13+
struct non_empty n;
14+
};
15+
16+
int main()
17+
{
18+
union U u;
19+
struct empty e = u.e;
20+
__CPROVER_assert(0, "dummy assertion");
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE broken-smt-backend
2+
main.c
3+
--trace
4+
^VERIFICATION FAILED$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
9+
Invariant check failed
10+
--
11+
Byte-extracting (which is what union operations yield) an empty struct should
12+
not result in a conversion warning in the flattening back-end.

src/solvers/flattening/boolbv_byte_extract.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
5959
}
6060
#endif
6161

62-
if(width==0)
63-
return conversion_failed(expr);
64-
6562
// see if the byte number is constant and within bounds, else work from the
6663
// root object
6764
const auto op_bytes_opt = pointer_offset_size(expr.op().type(), ns);

0 commit comments

Comments
 (0)