Skip to content

Commit

Permalink
Auto merge of #1260 - RalfJung:unreachable, r=RalfJung
Browse files Browse the repository at this point in the history
Implement unreachable intrinsic

Fixes #1254
  • Loading branch information
bors committed Mar 25, 2020
2 parents 5d8229e + 962e210 commit a84d8a8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/shims/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?
Expand Down
1 change: 1 addition & 0 deletions src/shims/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/compile-fail/unreachable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// error-pattern: entering unreachable code
fn main() {
unsafe { std::hint::unreachable_unchecked() }
}

0 comments on commit a84d8a8

Please # to comment.