-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
ICE when using offset intrinsic with an i32 #111699
Comments
The offset intrinsic does not support doing this, it requires isize or usize. ICEs using intrinsics wrongly are expected and not a bug. Thanks for the report anyways. |
Shouldn't a type coercion occur for the |
There is nothing to be coerced to, since the intrinsics accept any type on the type level. |
Is this specific to the
#![feature(core_intrinsics)]
use std::intrinsics::arith_offset;
fn main() {
let a = [1u8, 2, 3];
let ptr: *const u8 = a.as_ptr();
unsafe {
assert_eq!(*arith_offset(ptr, true), 1);
}
}
#![feature(core_intrinsics)]
use std::intrinsics::floorf32;
fn main() {
unsafe { floorf32(true); }
}
Doing the same for #![feature(core_intrinsics)]
use std::intrinsics::offset;
fn main() {
let a = [1u8, 2, 3];
let ptr: *const u8 = a.as_ptr();
unsafe {
assert_eq!(*offset(ptr, true), 1);
}
}
|
the |
It's only generic in the first parameter. And |
Hi @Nilstrieb, what is the motivation to keep this check as an ICE instead of a user friendly error since the error arises from misusage of the API? |
Giving better errors for intrinsics and other internal-only features increases maintenance burden, so MCP 620 decided to not support it. Invalid usage of intrinsics may lead to ICEs (since intrinsics should not be used - I see for your case here it makes sense to use them in the tests, but I think you can live with ICEs). I guess it's not ideal that the ICE message says to report it - but fixing that is hard. |
…, r=oli-obk Remove crashes for misuses of intrinsics All of these do not crash if the feature gate is removed. An ICE due *opting into* the intrinsics feature gate is not a bug that needs to be fixed, but instead a misuse of an internal-only API. See rust-lang/compiler-team#620 The last two issues are already closed anyways, but: Fixes rust-lang#97501 Fixes rust-lang#111699 Fixes rust-lang#101962
Code
Meta
rustc --version --verbose
:Error output
Backtrace
Adding an
isize
suffix fixes the issue:The error first appears with the
nightly-2023-04-29
toolchain. It works fine withnightly-2023-04-28
.The text was updated successfully, but these errors were encountered: