Add regression test for LLVM 17-rc3 miscompile
See #115385 for more details.
This commit is contained in:
parent
ab45885dec
commit
c18da3ccd4
50
tests/codegen/issues/issue-115385.rs
Normal file
50
tests/codegen/issues/issue-115385.rs
Normal file
@ -0,0 +1,50 @@
|
||||
// compile-flags: -O -Ccodegen-units=1
|
||||
// only-x86_64-unknown-linux-gnu
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#[repr(i64)]
|
||||
pub enum Boolean {
|
||||
False = 0,
|
||||
True = 1,
|
||||
}
|
||||
|
||||
impl Clone for Boolean {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl Copy for Boolean {}
|
||||
|
||||
extern "C" {
|
||||
fn set_value(foo: *mut i64);
|
||||
}
|
||||
|
||||
pub fn foo(x: bool) {
|
||||
let mut foo = core::mem::MaybeUninit::<i64>::uninit();
|
||||
unsafe {
|
||||
set_value(foo.as_mut_ptr());
|
||||
}
|
||||
|
||||
if x {
|
||||
let l1 = unsafe { *foo.as_mut_ptr().cast::<Boolean>() };
|
||||
if matches!(l1, Boolean::False) {
|
||||
unsafe {
|
||||
*foo.as_mut_ptr() = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let l2 = unsafe { *foo.as_mut_ptr() };
|
||||
if l2 == 2 {
|
||||
// CHECK: call void @bar
|
||||
bar();
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[inline(never)]
|
||||
pub fn bar() {
|
||||
println!("Working correctly!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user