Auto merge of #1260 - RalfJung:unreachable, r=RalfJung
Implement unreachable intrinsic Fixes https://github.com/rust-lang/miri/issues/1254
This commit is contained in:
commit
a84d8a8b98
4 changed files with 7 additions and 3 deletions
|
|
@ -106,8 +106,7 @@ impl MemoryExtra {
|
|||
pub fn init_extern_statics<'tcx, 'mir>(
|
||||
this: &mut MiriEvalContext<'mir, 'tcx>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let target_os = this.tcx.sess.target.target.target_os.as_str();
|
||||
match target_os {
|
||||
match this.tcx.sess.target.target.target_os.as_str() {
|
||||
"linux" => {
|
||||
// "__cxa_thread_atexit_impl"
|
||||
// This should be all-zero, pointer-sized.
|
||||
|
|
|
|||
|
|
@ -802,7 +802,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
|
||||
this.check_no_isolation("mkdir")?;
|
||||
|
||||
let _mode = if this.tcx.sess.target.target.target_os.as_str() == "macos" {
|
||||
let _mode = if this.tcx.sess.target.target.target_os == "macos" {
|
||||
u32::from(this.read_scalar(mode_op)?.not_undef()?.to_u16()?)
|
||||
} else {
|
||||
this.read_scalar(mode_op)?.to_u32()?
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
let (dest, ret) = match ret {
|
||||
None => match intrinsic_name {
|
||||
"miri_start_panic" => return this.handle_miri_start_panic(args, unwind),
|
||||
"unreachable" => throw_ub!(Unreachable),
|
||||
_ => throw_unsup_format!("unimplemented (diverging) intrinsic: {}", intrinsic_name),
|
||||
},
|
||||
Some(p) => p,
|
||||
|
|
|
|||
4
tests/compile-fail/unreachable.rs
Normal file
4
tests/compile-fail/unreachable.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
// error-pattern: entering unreachable code
|
||||
fn main() {
|
||||
unsafe { std::hint::unreachable_unchecked() }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue