Skip to content
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

future-incompat: use of SIMD types aren't gated properly #87438

Closed
JohnTitor opened this issue Jul 24, 2021 · 1 comment
Closed

future-incompat: use of SIMD types aren't gated properly #87438

JohnTitor opened this issue Jul 24, 2021 · 1 comment
Labels
A-FFI Area: Foreign function interface (FFI) A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. F-simd_ffi `#![feature(simd_ffi)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@JohnTitor
Copy link
Member

(Splitting from https://github.com/rust-lang/rust/pull/59238/files/8477a04a72a6f8e0adb46be91a2628b07648c200#r266976217)

Consider the following (playground):

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

#[allow(improper_ctypes)]
extern "C" {
    fn e(x: __m128);
}

which produces the following error (correctly):

error: use of SIMD type `__m128` in FFI is highly experimental and may result in invalid code
 --> src/lib.rs:5:13
  |
5 |     fn e(x: __m128);
  |             ^^^^^^
  |
  = help: add `#![feature(simd_ffi)]` to the crate attributes to enable

But when we use it on struct (playground):

#[repr(transparent)] pub struct A(__m128);
#[repr(C)] pub struct B(__m128);

it just compiles fine on stable Rust, while we should gate it. We should eventually disallow it through a future incompat lint.

@JohnTitor JohnTitor added C-bug Category: This is a bug. A-FFI Area: Foreign function interface (FFI) A-SIMD Area: SIMD (Single Instruction Multiple Data) F-simd_ffi `#![feature(simd_ffi)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2021
@RalfJung
Copy link
Member

With #116558, actually calling that imported function without having the required target features will cause a future-compat lint (eventually error). I'd say that closes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI) A-SIMD Area: SIMD (Single Instruction Multiple Data) C-bug Category: This is a bug. F-simd_ffi `#![feature(simd_ffi)]` 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