Confusing error when using `simd_masked_load` with the wrong type
Open
Nobody has claimed this yet.
A-diagnostics
A-SIMD
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#![feature(portable_simd, platform_intrinsics, adt_const_params, core_intrinsics)]
#![allow(incomplete_features, internal_features)]
use std::intrinsics::simd as intrinsics;
use std::ptr;
use std::simd::prelude::*;
pub fn simd_masked_loadstore() {
let val = 42u8;
let ptrs: Simd<*const u8, 4> =
Simd::from_array([ptr::null(), ptr::addr_of!(val), ptr::addr_of!(val), ptr::addr_of!(val)]);
let default = i8x4::splat(0);
let mask = i8x4::from_array([0, !0, 0, !0]);
let vals = unsafe { intrinsics::simd_masked_load(mask, ptrs, default) };
assert_eq!(vals, i8x4::from_array([0, 42, 0, 42]),);
}
This errors, saying:
error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic:
expected element type `i8` of second argument `std::simd::Simd<*const u8, 4>`
to be a pointer to the element type `i8` of the first argument `std::simd::Simd<i8, 4>`, found `i8` != `*_ i8`
However, the second argument has element type *const u8, even though the error says it has element type i8.
Actually the second argument should be a pointer. So talking about its "element type" doesn't even make a ton of sense.
Cc @farnoy
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 compiling the provided Rust reproduction and inspect the diagnostic path for the simd_masked_load intrinsic. Done means the error accurately describes the pointer argument and avoids misleadingly calling its pointee type the argument's element type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100