We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
bool
size_t
2 parents 03b949c + 28cad01 commit 73bdbb8Copy full SHA for 73bdbb8
c2rust-transpile/src/translator/mod.rs
@@ -4282,6 +4282,13 @@ impl<'c> Translation<'c> {
4282
target_ty,
4283
)))
4284
})
4285
+ } else if target_ty_ctype.is_pointer() && source_ty_kind.is_bool() {
4286
+ val.and_then(|x| {
4287
+ Ok(WithStmts::new_val(mk().cast_expr(
4288
+ mk().cast_expr(x, mk().path_ty(vec!["libc", "size_t"])),
4289
+ target_ty,
4290
+ )))
4291
+ })
4292
} else {
4293
// Other numeric casts translate to Rust `as` casts,
4294
// unless the cast is to a function pointer then use `transmute`.
tests/casts/src/casts.c
@@ -30,4 +30,5 @@ void cast_stuff(void) {
30
31
bool b = true;
32
float x15 = b;
33
+ void* x16 = (void*)b;
34
}
0 commit comments