Skip to content

implement #[repr(align)] (tracking issue for RFC 1358) #33626

Closed
@nikomatsakis

Description

@nikomatsakis
Contributor

Tracking issue for rust-lang/rfcs#1358

Activity

added
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
T-langRelevant to the language team
B-unstableBlocker: Implemented in the nightly compiler and unstable.
on May 13, 2016
kennytm

kennytm commented on Jun 28, 2016

@kennytm
Member

heap::EMPTY is currently defined as 1 and is used as the address of reference to zero-sized types. Would it affect the program's correctness if we change the alignment of a ZST?

#[repr(align="8")]
struct F;

println!("{:p}", Box::new(F));
// prints 0x1? 0x8?

cc #27700.

retep998

retep998 commented on Jun 28, 2016

@retep998
Member

@kennytm That already is an issue without this RFC.

use std::mem::align_of;
struct F([u32; 0]);
println!("{:p}", Box::new(F)); //prints 0x1
println!("{}", align_of::<F>()); //prints 4
kennytm

kennytm commented on Jun 28, 2016

@kennytm
Member

@retep998 Okay thanks. So it is entirely an issue of #27700.

whitequark

whitequark commented on Oct 5, 2016

@whitequark
Member

Anyone else implementing this? I need it so I may give it a go.

mfarrugi

mfarrugi commented on Nov 17, 2016

@mfarrugi

What's the relationship of this issue to simd support #27731 (ie. the current way to accomplish this on nightly)?

Can/should this be implemented separately?

lu-zero

lu-zero commented on Jan 5, 2017

@lu-zero
Contributor

@mfarrugi the two are related but not that much. SIMD usually works better on aligned data, but you need aligned data also when you use other kind of hardware features (dma engines for crypto, video decoding/encoding, etc). @whitequark got time to implement it? From what I can see the allocator now is taking an alignment so it should be not terrible to implement (I do not know the rust internals well enough to be confident in poking around this).

whitequark

whitequark commented on Jan 6, 2017

@whitequark
Member

@lu-zero Ok let me give it another try. Rustbuild and (hopefully?) incremental compilation have made rustc hacking much less painful...

bitshifter

bitshifter commented on Jan 14, 2017

@bitshifter
Contributor

@whitequark have started on this? I was interested and got a proof of concept working, so if you haven't started on it I could probably finish off what I'm doing and make a PR. I'd probably need some mentoring from someone, I haven't added a feature before.

whitequark

whitequark commented on Jan 14, 2017

@whitequark
Member

@bitshifter not really, please go ahead!

102 remaining items

bitshifter

bitshifter commented on Dec 25, 2017

@bitshifter
Contributor

I've created a pull request for stabilization, I still need to update the reference. I wasn't planning on updating the book or rust by example as they don't appear to talk about repr hints.

bitshifter

bitshifter commented on Dec 26, 2017

@bitshifter
Contributor

I have not updated the reference Attribute syntax grammar documentation as the new syntax is only used by #[repr(align)] and I thought it might be pretty confusing to include a grammar which is only used by one kind of attribute for now.

whitequark

whitequark commented on Mar 30, 2018

@whitequark
Member

I think this can be closed now since the attribute is stable.

gnzlbg

gnzlbg commented on Apr 13, 2018

@gnzlbg
Contributor

@kennytm can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @briansmith@whitequark@alexcrichton@eddyb@kennytm

        Issue actions

          implement `#[repr(align)]` (tracking issue for RFC 1358) · Issue #33626 · rust-lang/rust