diff --git a/cpp2rust/converter/converter.cpp b/cpp2rust/converter/converter.cpp index 244826bf55..3ec2d1c27d 100644 --- a/cpp2rust/converter/converter.cpp +++ b/cpp2rust/converter/converter.cpp @@ -2720,6 +2720,7 @@ bool Converter::VisitImplicitCastExpr(clang::ImplicitCastExpr *expr) { } case clang::CastKind::CK_ConstructorConversion: case clang::CastKind::CK_DerivedToBase: + case clang::CastKind::CK_UncheckedDerivedToBase: Convert(sub_expr); break; case clang::CastKind::CK_IntegralToBoolean: diff --git a/tests/unit/out/refcount/stdcopy_ostream.rs b/tests/unit/out/refcount/stdcopy_ostream.rs index 48df1e1595..289cec9c2d 100644 --- a/tests/unit/out/refcount/stdcopy_ostream.rs +++ b/tests/unit/out/refcount/stdcopy_ostream.rs @@ -38,7 +38,38 @@ fn main_0() -> i32 { __out.try_clone().unwrap() } }; + write!(ofs.as_pointer(), "{:}", 42,); } + let mut f: Ptr = match CFile::open( + &file.decay().to_rust_string(), + &Ptr::::from_string_literal(b"rb").to_rust_string(), + ) { + Some(__f) => Ptr::alloc(__f), + None => Ptr::null(), + }; + let buf: Value> = Rc::new(RefCell::new(Box::new([ + 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, + 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, 0_i8, + 0_i8, 0_i8, + ]))); + let mut n: usize = libcc2rs::fread_refcount( + (buf.decay()).to_any(), + 1_usize, + ::std::mem::size_of::<[i8; 32]>(), + (f).clone(), + ); + { + let __r = f.with(|__f| __f.close()); + f.delete(); + __r + }; + assert!((n == 16_usize)); + assert!( + ({ + (((*buf.borrow())[(14) as usize] as i32) == (('4' as i8) as i32)) + && (((*buf.borrow())[(15) as usize] as i32) == (('2' as i8) as i32)) + }) + ); match nix::unistd::unlink(file.decay().to_rust_string().as_str()) { Ok(()) => 0, Err(__e) => { diff --git a/tests/unit/out/unsafe/stdcopy_ostream.rs b/tests/unit/out/unsafe/stdcopy_ostream.rs index 298056cb50..9f17f4c2e2 100644 --- a/tests/unit/out/unsafe/stdcopy_ostream.rs +++ b/tests/unit/out/unsafe/stdcopy_ostream.rs @@ -41,7 +41,55 @@ unsafe fn main_0() -> i32 { __out.try_clone().unwrap() } }; + write!(ofs, "{:}", 42,); } + let mut f: *mut ::libc::FILE = libc::fopen(file.as_ptr(), c"rb".as_ptr()); + let mut buf: [libc::c_char; 32] = [ + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + (0 as libc::c_char), + ]; + let mut n: usize = libcc2rs::fread_unsafe( + (buf.as_mut_ptr() as *mut ::libc::c_void), + 1_usize, + ::std::mem::size_of::<[libc::c_char; 32]>(), + f, + ); + libc::fclose(f); + assert!(((n) == (16_usize))); + assert!( + ((buf[(14) as usize] as i32) == (('4' as libc::c_char) as i32)) + && ((buf[(15) as usize] as i32) == (('2' as libc::c_char) as i32)) + ); libc::unlink(file.as_ptr()); return 0; } diff --git a/tests/unit/stdcopy_ostream.cpp b/tests/unit/stdcopy_ostream.cpp index 523188cfbf..d0bdbc3343 100644 --- a/tests/unit/stdcopy_ostream.cpp +++ b/tests/unit/stdcopy_ostream.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -10,7 +12,14 @@ int main() { { std::ofstream ofs(file, std::ios::binary); std::copy(str.begin(), str.end(), std::ostream_iterator(ofs)); + ofs << 42; } + FILE *f = fopen(file, "rb"); + char buf[32] = {0}; + size_t n = fread(buf, 1, sizeof(buf), f); + fclose(f); + assert(n == 16); + assert(buf[14] == '4' && buf[15] == '2'); unlink(file); return 0; }