Skip to content

u128 alignment is incorrect on x86_64 #54949

Closed
@strega-nil

Description

@strega-nil
Contributor

In C and C++, on x86_64 Linux, alignof(__int128) is equal to 16. However, in Rust, align_of::<u128>() is equal to 8.

C++: https://gcc.godbolt.org/z/YAq1XC
Rust: https://gcc.godbolt.org/z/QvZeqK

This will cause subtle UB if you ever try to use i128s across FFI boundaries; for example:

C++: https://gcc.godbolt.org/z/PrtHlp
Rust: https://gcc.godbolt.org/z/_SdVqD

Activity

changed the title [-]u128 ABI is incorrect[/-] [+]u128 alignment is incorrect on x86_64[/+] on Oct 10, 2018
leonardo-m

leonardo-m commented on Oct 10, 2018

@leonardo-m

See also: #54341

nagisa

nagisa commented on Oct 10, 2018

@nagisa
Member

Duplicate of #54341, yes.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nagisa@strega-nil@leonardo-m

        Issue actions

          u128 alignment is incorrect on x86_64 · Issue #54949 · rust-lang/rust