Skip to content

Commit 83ded08

Browse files
committed
transpile: operators: track volatile writes as being unsafe
1 parent 5d7d979 commit 83ded08

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

c2rust-transpile/src/translator/operators.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl<'c> Translation<'c> {
446446
let assign_stmt = match op {
447447
// Regular (possibly volatile) assignment
448448
Assign if !is_volatile => WithStmts::new_val(mk().assign_expr(write, rhs)),
449-
Assign => WithStmts::new_val(self.volatile_write(
449+
Assign => WithStmts::new_unsafe_val(self.volatile_write(
450450
write,
451451
initial_lhs_type_id,
452452
rhs,
@@ -501,7 +501,7 @@ impl<'c> Translation<'c> {
501501

502502
let write = if is_volatile {
503503
val.and_then(|val| {
504-
TranslationResult::Ok(WithStmts::new_val(
504+
TranslationResult::Ok(WithStmts::new_unsafe_val(
505505
self.volatile_write(write, initial_lhs_type_id, val)?,
506506
))
507507
})?
@@ -887,6 +887,7 @@ impl<'c> Translation<'c> {
887887

888888
// *p = *p + rhs
889889
let assign_stmt = if ty.qualifiers.is_volatile {
890+
is_unsafe = true;
890891
self.volatile_write(write, ty, val)?
891892
} else {
892893
mk().assign_expr(write, val)

0 commit comments

Comments
 (0)