You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(c2rust-analyze) Support ptr-to-ptr casts between safely transmutable types, for now limited to same-sized integers (#839)
- Fixes#840
This introduces the concept of equivalent/compatible/safely transmutable
types:
https://github.com/immunant/c2rust/blob/2915b8d0c71add21dee1f9d540958ea863478212/c2rust-analyze/src/util.rs#L356-L380
Thus, we can now allow ptr-to-ptr casts between safely transmutable
pointee types, whereas previously they were only allowed for equal
types. In particular, this enables support for string casts, which are
produced by `c2rust transpile` as `b"" as *const u8 as *const
core::ffi::c_char`, where `c_char = i8`. Thus, this fixes#840.
New tests are added in `string_casts.rs` to cover various ptr casts,
though some of them crash in the rewriter due to having implicitly
inserted MIR statements like implicit `&raw`s, which are inserted with
`addr_of!`s. Thus, for some of these (where it works), there are
versions with explicit `addr_of!`s that succeed end-to-end.
Some(false) => ::log::error!("TODO: unsupported ptr-to-ptr cast between pointee types not yet supported as safely transmutable: `{from_ty:?} as {to_ty:?}`"),
147
+
None => {},// not a ptr cast (no dataflow constraints needed); let rustc typeck this
0 commit comments