-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
While fixing various bindgen bugs related to long double
, int128
, (rust-lang/rust-bindgen#1370, etc).
I realized that the following Rust program, in my x86_64 Linux machine:
#[repr(C)]
struct Foo {
f: u128,
}
fn main() {
println!("Align: {}", ::std::mem::align_of::<Foo>());
}
Prints 8
.
While the following C program:
#include <stdio.h>
struct foo {
unsigned __int128 t;
};
int main() {
printf("Align: %ld\n", _Alignof(struct foo));
}
Prints 16
on the same system. This is pretty unexpected, and means that i128 / u128 are not really usable for FFI / alignment purposes.
schneiderfelipeacheroncrypto
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.