immunant / c2rust

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

Missing semicolon after volatile pointer cast. #1049

Open ahaoboy opened 7 months ago

ahaoboy commented 7 months ago
 c2rust --version
C2Rust 0.18.0 (2023-12-03)

C

#include <stdio.h>
int main()
{
  const char *volatile str = NULL;
  int c = (unsigned char)*str++;
  return 0;
}

Output

use ::libc;
unsafe fn main_0() -> libc::c_int {
    let mut str: *const libc::c_char = 0 as *const libc::c_char;
    let fresh0 = ::core::ptr::read_volatile::<
        *const libc::c_char,
    >(&str as *const *const libc::c_char);
    ::core::ptr::write_volatile(
        &mut str as *mut *const libc::c_char,
        (::core::ptr::read_volatile::<
            *const libc::c_char,
        >(&str as *const *const libc::c_char))
            .offset(1),
    )
    let mut c: libc::c_int = *fresh0 as libc::c_uchar as libc::c_int;
    return 0 as libc::c_int;
}
pub fn main() {
    unsafe { ::std::process::exit(main_0() as i32) }
}