]> git.lizzy.rs Git - rust.git/blob - src/test/ui/print_type_sizes/repr-align.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / print_type_sizes / repr-align.rs
1 // compile-flags: -Z print-type-sizes
2 // compile-pass
3
4 // This file illustrates how padding is handled: alignment
5 // requirements can lead to the introduction of padding, either before
6 // fields or at the end of the structure as a whole.
7 //
8 // It avoids using u64/i64 because on some targets that is only 4-byte
9 // aligned (while on most it is 8-byte aligned) and so the resulting
10 // padding and overall computed sizes can be quite different.
11 #![feature(start)]
12 #![allow(dead_code)]
13
14 #[repr(align(16))]
15 #[derive(Default)]
16 struct A(i32);
17
18 enum E {
19     A(i32),
20     B(A)
21 }
22
23 #[derive(Default)]
24 struct S {
25     a: i32,
26     b: i32,
27     c: A,
28     d: i8,
29 }
30
31 #[start]
32 fn start(_: isize, _: *const *const u8) -> isize {
33     let _s: S = Default::default();
34     0
35 }