Skip to content

Commit

Permalink
Add a test for #107975
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigorenkoPV committed Jun 26, 2024
1 parent 4bc39f0 commit 3cbb6e4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/ui/codegen/nondetermenistic-int-expose-provenance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ run-pass
//@ known-bug: #107975

#![feature(exposed_provenance)]

use std::ptr::addr_of;

fn main() {
let a: usize = {
let v = 0u8;
addr_of!(v).expose_provenance()
};
let b: usize = {
let v = 0u8;
addr_of!(v).expose_provenance()
};
let i: usize = a - b;
assert_ne!(i, 0);
println!("{}", i);
assert_eq!(i, 0);
}
17 changes: 17 additions & 0 deletions tests/ui/codegen/nondetermenistic-int-regular.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ run-pass
//@ known-bug: #107975

fn main() {
let a: usize = {
let v = 0u8;
&v as *const _ as usize
};
let b: usize = {
let v = 0u8;
&v as *const _ as usize
};
let i: usize = a - b;
assert_ne!(i, 0);
println!("{}", i);
assert_eq!(i, 0);
}
21 changes: 21 additions & 0 deletions tests/ui/codegen/nondetermenistic-int-strict-provenance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ run-pass
//@ known-bug: #107975

#![feature(strict_provenance)]

use std::ptr::addr_of;

fn main() {
let a: usize = {
let v = 0u8;
addr_of!(v).addr()
};
let b: usize = {
let v = 0u8;
addr_of!(v).addr()
};
let i: usize = a - b;
assert_ne!(i, 0);
println!("{}", i);
assert_eq!(i, 0);
}

0 comments on commit 3cbb6e4

Please sign in to comment.