immunant / c2rust

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

Currently neither field expressions (e.g. `my_struct.x`) nor field type declarations (e.g. `x: *mut i32`) get rewritten. #873

Open aneksteind opened 1 year ago

aneksteind commented 1 year ago
          Currently neither field expressions (e.g. `my_struct.x`) nor field type declarations (e.g. `x: *mut i32`) get rewritten.

_Originally posted by @spernsteiner in https://github.com/immunant/c2rust/pull/815#discussion_r1119219040_

spernsteiner commented 1 year ago

Lack of rewriting of field types is a major source of compilation errors on lighttpd. For example:

error[E0608]: cannot index into a value of type `*mut i8`
    --> ../src/main.new.rs:5992:12
     |
5992 |         &(&(((*hdr).buf))[(((*hdr).name_offset as libc::c_int as isize) as usize) ..])[0]
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The problem here is that the buf field hasn't been rewritten into a slice.

aneksteind commented 1 year ago

I'm working on this