`extern { fn f(_: *const __m128); }` emits `improper_ctypes`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Rust example with rustc 1.84.0 and inspect the improper_ctypes diagnostic for raw-pointer parameters. Compare it with the linked issue's by-value __m128 case; done means the pointer form no longer emits the warning while the relevant FFI checks remain intact, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100