File tree 2 files changed +36
-0
lines changed 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -33,3 +33,34 @@ fn bindgen_test_layout_a() {
33
33
concat!( "Offset of field: " , stringify!( a) , "::" , stringify!( c) )
34
34
) ;
35
35
}
36
+ #[ repr( C ) ]
37
+ #[ repr( align( 8 ) ) ]
38
+ #[ derive( Debug , Default , Copy , Clone ) ]
39
+ pub struct b {
40
+ pub b : :: std:: os:: raw:: c_int ,
41
+ pub c : :: std:: os:: raw:: c_int ,
42
+ pub __bindgen_align : [ u64 ; 0usize ] ,
43
+ }
44
+ #[ test]
45
+ fn bindgen_test_layout_b ( ) {
46
+ assert_eq ! (
47
+ :: std:: mem:: size_of:: <b>( ) ,
48
+ 8usize ,
49
+ concat!( "Size of: " , stringify!( b) )
50
+ ) ;
51
+ assert_eq ! (
52
+ :: std:: mem:: align_of:: <b>( ) ,
53
+ 8usize ,
54
+ concat!( "Alignment of " , stringify!( b) )
55
+ ) ;
56
+ assert_eq ! (
57
+ unsafe { & ( * ( :: std:: ptr:: null:: <b>( ) ) ) . b as * const _ as usize } ,
58
+ 0usize ,
59
+ concat!( "Offset of field: " , stringify!( b) , "::" , stringify!( b) )
60
+ ) ;
61
+ assert_eq ! (
62
+ unsafe { & ( * ( :: std:: ptr:: null:: <b>( ) ) ) . c as * const _ as usize } ,
63
+ 4usize ,
64
+ concat!( "Offset of field: " , stringify!( b) , "::" , stringify!( c) )
65
+ ) ;
66
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,8 @@ struct alignas(8) a {
4
4
int b;
5
5
int c;
6
6
};
7
+
8
+ struct alignas (double ) b {
9
+ int b;
10
+ int c;
11
+ };
You can’t perform that action at this time.
0 commit comments