Skip to content

Quirks of #repr(align()) errors #49492

Closed
Closed
@glandium

Description

@glandium

2GiB alignments fail:

error[E0589]: invalid `repr(align)` attribute: larger than 2147483647
  --> src/main.rs:11:8
   |
11 | #[repr(align(2147483648))]
   |        ^^^^^^^^^^^^^^^^^

which could be considered fine, although I don't see why, besides the Layout::from_size_align limitation which I think is wrong (#32838 (comment)). But that's besides the point. The error message is kind of pointless talking about 2GiB - 1:

error[E0589]: invalid `repr(align)` attribute: not a power of two
  --> src/main.rs:11:8
   |
11 | #[repr(align(2147483647))]
   |        ^^^^^^^^^^^^^^^^^

Because any value larger than 1GiB will actually fail too because they're not powers of two.

Also, The error is unknown on error-index.html: https://doc.rust-lang.org/error-index.html#E0589

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions