Skip to content

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

Open
@zopsicle

Description

@zopsicle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsL-false-positiveLint: False positive (should not have fired).L-improper_ctypesLint: improper_ctypesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions