
Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. This function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec. This is hopefully rare enough to not break anything.
29 lines
525 B
Rust
29 lines
525 B
Rust
// compile-flags: -C no-prepopulate-passes
|
|
|
|
// ignore-riscv64
|
|
|
|
#![feature(link_llvm_intrinsics)]
|
|
#![crate_type = "lib"]
|
|
|
|
struct A;
|
|
|
|
impl Drop for A {
|
|
fn drop(&mut self) {
|
|
println!("A");
|
|
}
|
|
}
|
|
|
|
extern "C" {
|
|
#[link_name = "llvm.sqrt.f32"]
|
|
fn sqrt(x: f32) -> f32;
|
|
}
|
|
|
|
pub fn do_call() {
|
|
let _a = A;
|
|
|
|
unsafe {
|
|
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
|
|
// CHECK: call noundef float @llvm.sqrt.f32(float noundef 4.000000e+00
|
|
sqrt(4.0);
|
|
}
|
|
}
|