c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

`c2rust transpile` produces `gettimeofday` call with wrong argument type when reorganizing definitions

Open Ravenslofty opened this issue 5 years ago • 1 comments

Steps to reproduce:

  • git clone https://github.com/ZirconiumX/Dorpsgek
  • intercept-build make
  • c2rust transpile --binary main --reorganize-definitions compile_commands.json

Expected result:

Code compiles cleanly

Actual result:

error[E0308]: mismatched types
   --> time.rs:115:68
    |
115 |     ::libc::gettimeofday(&mut t as *mut _ as *mut ::libc::timeval, 0 as *mut libc::c_void);
    |                                                                    ^^^^^^^^^^^^^^^^^^^^^^ expected enum `libc::timezone`, found enum `libc::c_void`
    |
    = note: expected raw pointer `*mut libc::timezone`
               found raw pointer `*mut libc::c_void`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
thread 'main' panicked at 'Could not rebuild crate: could not compile `c2rust_out`.

Something to note is that this translates fine without --reorganize-definitions.

Ravenslofty avatar Jun 15 '20 17:06 Ravenslofty

This issue is also triggered when translating nginx with --reorganize-definitions enabled. I've temporarily disabled reorganize definitions in the c2rust-testsuite until this issue is resolved.

thedataking avatar Jul 06 '20 22:07 thedataking