Skip to content

Commit 80186e3

Browse files
authored
Merge pull request #6683 from tautschnig/bugfixes/mmio-cast
MMIO rewriting must maintain type consistency
2 parents 79c1637 + 871d3a5 commit 80186e3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

regression/cbmc/mm_io1/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ int main()
1616
{
1717
long i=0x10;
1818
char *p=(char *)i;
19+
unsigned char u = *(unsigned char *)i;
1920
char some_var=100;
2021

2122
char z;

src/goto-programs/mm_io.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ void mm_io(
6262
source_locationt source_location = it->source_location();
6363
const code_typet &ct=to_code_type(mm_io_r.type());
6464

65-
if_exprt if_expr(integer_address(d.pointer()), mm_io_r_value, d);
65+
if_exprt if_expr(
66+
integer_address(d.pointer()),
67+
typecast_exprt::conditional_cast(mm_io_r_value, d.type()),
68+
d);
6669
replace_expr(d, if_expr, a_rhs);
6770

6871
const typet &pt=ct.parameters()[0].type();

0 commit comments

Comments
 (0)