Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple alignments on functions (#![feature(fn_align)]) #132464

Open
jdonszelmann opened this issue Nov 1, 2024 · 1 comment
Open

Multiple alignments on functions (#![feature(fn_align)]) #132464

jdonszelmann opened this issue Nov 1, 2024 · 1 comment
Assignees
Labels
A-align Area: alignment control (`repr(align(N))` and so on) A-repr Area: the `#[repr(stuff)]` attribute C-bug Category: This is a bug. F-fn_align `#![feature(fn_align)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Nov 1, 2024

This code specifies two alignments, but applies none. A single align(256) does work

#![feature(fn_align)]


#[repr(align(256), align(256))]
pub fn main() {
    let ptr = main as *const u8;
    println!("{ptr:?}");

    assert_eq!(ptr.align_offset(256), 0);
}

See here: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f841ae6318f0f7abdab285ea9ec641ab

CC: #82232

The culprit is this line here matching on slices of length 1:

codegen_fn_attrs.alignment = if let Some(items) = attr.meta_item_list()
&& let [item] = items.as_slice()
&& let Some((sym::align, literal)) = item.singleton_lit_list()

It's a one line fix, but honestly this is trivially resolved with rust-lang/compiler-team#796 which I'm working on. I'll make it a separate PR at some point, but I'll assign myself since it makes sure changes conflict a little less :)

@rustbot claim

@jdonszelmann jdonszelmann added the C-bug Category: This is a bug. label Nov 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 1, 2024
@jieyouxu jieyouxu added F-fn_align `#![feature(fn_align)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 1, 2024
@workingjubilee workingjubilee added A-align Area: alignment control (`repr(align(N))` and so on) and removed F-fn_align `#![feature(fn_align)]` labels Nov 1, 2024
@jdonszelmann
Copy link
Contributor Author

@rustbot label +A-repr +A-align

@rustbot rustbot added the A-repr Area: the `#[repr(stuff)]` attribute label Nov 1, 2024
@workingjubilee workingjubilee added F-fn_align `#![feature(fn_align)]` A-align Area: alignment control (`repr(align(N))` and so on) and removed A-align Area: alignment control (`repr(align(N))` and so on) labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-align Area: alignment control (`repr(align(N))` and so on) A-repr Area: the `#[repr(stuff)]` attribute C-bug Category: This is a bug. F-fn_align `#![feature(fn_align)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants