Skip to content

Commit cc63bde

Browse files
committed
Enforce dereferencing bitvectors requiring a size that is multiple of 8.
1 parent 2cd4154 commit cc63bde

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,17 @@ void c_typecheck_baset::typecheck_expr_dereference(exprt &expr)
18051805
error() << "dereferencing void pointer" << eom;
18061806
throw 0;
18071807
}
1808+
1809+
if(is_signed_or_unsigned_bitvector(expr.type()))
1810+
{
1811+
auto bv_type_width = to_bitvector_type(expr.type()).get_width();
1812+
if(bv_type_width % 8 != 0)
1813+
{
1814+
throw invalid_source_file_exceptiont{
1815+
"only bitvectors of size multiple of 8 can be dereferenced",
1816+
expr.source_location()};
1817+
}
1818+
}
18081819
}
18091820
else
18101821
{

0 commit comments

Comments
 (0)