Skip to content

extern { fn f(_: *const __m128); } emits improper_ctypes #135993

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

Open
zopsicle opened this issue Jan 24, 2025 · 1 comment
Open

extern { fn f(_: *const __m128); } emits improper_ctypes #135993

zopsicle opened this issue Jan 24, 2025 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints L-false-positive Lint: False positive (should not have fired). L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zopsicle
Copy link
Contributor

zopsicle commented Jan 24, 2025

Code

use std::arch::x86_64::__m128;

extern
{
    fn f(_: *const __m128);
}

Current output

warning: `extern` block uses type `__m128`, which is not FFI-safe
 --> <source>:5:13
  |
5 |     fn f(_: *const __m128);
  |             ^^^^^^^^^^^^^ not FFI-safe
  |
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout
  = note: `#[warn(improper_ctypes)]` on by default

Desired output

Rationale and extra context

I don’t see why passing *const __m128 over FFI could cause ABI problems (as opposed to passing __m128 by value, which is known to miscompile). C and Rust agree on the size and alignment of __m128, and for extern functions, on the argument passing convention for pointers.

Other cases

Rust Version

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Anything else?

No response

@zopsicle zopsicle added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 24, 2025
@fee1-dead fee1-dead added L-improper_ctypes Lint: improper_ctypes L-false-positive Lint: False positive (should not have fired). labels Jan 25, 2025
@fee1-dead
Copy link
Member

cc #116963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints L-false-positive Lint: False positive (should not have fired). L-improper_ctypes Lint: improper_ctypes 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

2 participants