Skip to content

Commit 1923985

Browse files
committed
tests: Add a test for alignas(double).
1 parent cd733a6 commit 1923985

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/expectations/tests/repr-align.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,34 @@ fn bindgen_test_layout_a() {
3333
concat!("Offset of field: ", stringify!(a), "::", stringify!(c))
3434
);
3535
}
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+
}

tests/headers/repr-align.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ struct alignas(8) a {
44
int b;
55
int c;
66
};
7+
8+
struct alignas(double) b {
9+
int b;
10+
int c;
11+
};

0 commit comments

Comments
 (0)