File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,6 +347,9 @@ bool RustSizeDivergesFromC(clang::QualType qt) {
347347 if (auto *arr = qt->getAsArrayTypeUnsafe ()) {
348348 return RustSizeDivergesFromC (arr->getElementType ());
349349 }
350+ if (qt->isPointerType ()) {
351+ return true ;
352+ }
350353 return false ;
351354}
352355
Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ use std::io::prelude::*;
66use std:: io:: { Read , Seek , Write } ;
77use std:: os:: fd:: AsFd ;
88use std:: rc:: { Rc , Weak } ;
9+ const _: ( ) = assert ! (
10+ ( :: std:: mem:: size_of:: <usize >( ) == 8usize ) ,
11+ "sizeof(std::size_t) == sizeof(void *)"
12+ ) ;
13+ const _: ( ) = assert ! ( ( 8usize == 8_usize ) , "sizeof(int *) == 8" ) ;
914pub fn main ( ) {
1015 __cpp2rust_init_globals ( ) ;
1116 std:: process:: exit ( main_0 ( ) ) ;
@@ -42,6 +47,8 @@ fn main_0() -> i32 {
4247 assert ! ( ( ( xld * 2_f64 ) == 3_f64 ) ) ;
4348 assert ! ( ( ( ( ( xwc + ( xc8 as i32 ) ) + ( xc16 as i32 ) ) as u32 ) . wrapping_add( xc32) == 266_u32 ) ) ;
4449 assert ! ( ( AnyPtr :: default ( ) ) . is_null( ) ) ;
50+ let mut ip: Ptr < i32 > = Ptr :: < i32 > :: null ( ) ;
51+ assert ! ( ( 8usize == 8usize ) ) ;
4552 return 0 ;
4653}
4754pub fn __cpp2rust_init_globals ( ) { }
Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ use std::collections::BTreeMap;
66use std:: io:: { Read , Seek , Write } ;
77use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
88use std:: rc:: Rc ;
9+ const _: ( ) = assert ! (
10+ ( ( :: std:: mem:: size_of:: <usize >( ) ) == ( :: std:: mem:: size_of:: <* mut :: libc:: c_void>( ) ) ) ,
11+ "sizeof(std::size_t) == sizeof(void *)"
12+ ) ;
13+ const _: ( ) = assert ! (
14+ ( ( :: std:: mem:: size_of:: <* mut i32 >( ) ) == ( 8_usize ) ) ,
15+ "sizeof(int *) == 8"
16+ ) ;
917pub fn main ( ) {
1018 unsafe {
1119 __cpp2rust_init_globals ( ) ;
@@ -44,6 +52,10 @@ unsafe fn main_0() -> i32 {
4452 assert ! ( ( ( ( xld) * ( 2_f64 ) ) == ( 3_f64 ) ) ) ;
4553 assert ! ( ( ( ( ( ( ( xwc) + ( xc8 as i32 ) ) + ( xc16 as i32 ) ) as u32 ) . wrapping_add( xc32) ) == ( 266_u32 ) ) ) ;
4654 assert ! ( ( std:: ptr:: null_mut:: <:: libc:: c_void>( ) ) . is_null( ) ) ;
55+ let mut ip: * mut i32 = std:: ptr:: null_mut ( ) ;
56+ assert ! (
57+ ( ( :: std:: mem:: size_of:: <* mut i32 >( ) ) == ( :: std:: mem:: size_of:: <* mut :: libc:: c_void>( ) ) )
58+ ) ;
4759 return 0 ;
4860}
4961pub unsafe fn __cpp2rust_init_globals ( ) { }
Original file line number Diff line number Diff line change 55#include < cstdint>
66#include < inttypes.h>
77
8+ static_assert (sizeof (std::size_t ) == sizeof (void *), " " );
9+ static_assert (sizeof (int *) == 8 , " " );
10+
811int main () {
912 const uint8_t xu8 = 8 ;
1013 const uint16_t xu16 = 16 ;
@@ -27,5 +30,7 @@ int main() {
2730 assert (xld * 2 == 3 );
2831 assert (xwc + xc8 + xc16 + xc32 == 266 );
2932 assert (xnp == nullptr );
33+ int *ip = nullptr ;
34+ assert (sizeof (ip) == sizeof (void *));
3035 return 0 ;
3136}
You can’t perform that action at this time.
0 commit comments