diff --git a/c2rust-transpile/src/translator/mod.rs b/c2rust-transpile/src/translator/mod.rs index 10ba422ee2..91b79a274a 100644 --- a/c2rust-transpile/src/translator/mod.rs +++ b/c2rust-transpile/src/translator/mod.rs @@ -4282,6 +4282,13 @@ impl<'c> Translation<'c> { target_ty, ))) }) + } else if target_ty_ctype.is_pointer() && source_ty_kind.is_bool() { + val.and_then(|x| { + Ok(WithStmts::new_val(mk().cast_expr( + mk().cast_expr(x, mk().path_ty(vec!["libc", "size_t"])), + target_ty, + ))) + }) } else { // Other numeric casts translate to Rust `as` casts, // unless the cast is to a function pointer then use `transmute`. diff --git a/tests/casts/src/casts.c b/tests/casts/src/casts.c index 1222683017..f881e46314 100644 --- a/tests/casts/src/casts.c +++ b/tests/casts/src/casts.c @@ -30,4 +30,5 @@ void cast_stuff(void) { bool b = true; float x15 = b; + void* x16 = (void*)b; }