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