immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.93k stars 230 forks source link

analyze: offset permission may be back-propagated too far #890

Open aneksteind opened 1 year ago

aneksteind commented 1 year ago

I think the rewriting bug I thought this original solution had fixed (but didn't) is because of the propagation of the offset permission not taking into account that the original type is already an array type that can be offset (so it rewrites it with an extra []). Maybe the propagation upward should only go as far as the as_ptr call. WDYT?

Sounds plausible to me. And I think your proposed fix sounds good - the *mut T output of as_ptr might be OFFSET even when the *mut [T; N] input is not. So as_ptr should not propagate OFFSET from its output to its input.

Originally posted by @spernsteiner in https://github.com/immunant/c2rust/issues/883#issuecomment-1512055429