diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-04-20 12:52:50 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-04-20 13:08:53 +0200 |
| commit | 2d21c140154c5387712938dbc2ca427e2df4dfc2 (patch) | |
| tree | 38368811ee7d2788d5183a747a1924f9586a3f2f /src/tools | |
| parent | 49e5e4e3a5610c240a717cb99003a5d5d3356679 (diff) | |
| download | rust-2d21c140154c5387712938dbc2ca427e2df4dfc2.tar.gz rust-2d21c140154c5387712938dbc2ca427e2df4dfc2.zip | |
respect `repr(align(N))` on functions in miri
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/miri/tests/pass/fn_align.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass/fn_align.rs b/src/tools/miri/tests/pass/fn_align.rs new file mode 100644 index 00000000000..550bb1cb4d7 --- /dev/null +++ b/src/tools/miri/tests/pass/fn_align.rs @@ -0,0 +1,21 @@ +//@compile-flags: -Zmin-function-alignment=8 +#![feature(fn_align)] + +// When a function uses `repr(align(N))`, the function address should be a multiple of `N`. + +#[repr(align(256))] +fn foo() {} + +#[repr(align(16))] +fn bar() {} + +#[repr(align(4))] +fn baz() {} + +fn main() { + assert!((foo as usize).is_multiple_of(256)); + assert!((bar as usize).is_multiple_of(16)); + + // The maximum of `repr(align(N))` and `-Zmin-function-alignment=N` is used. + assert!((baz as usize).is_multiple_of(8)); +} |
