Skip to content

Commit

Permalink
Merge pull request #324 from oli-obk/align_offset
Browse files Browse the repository at this point in the history
Implement `align_offset` intrinsic and thus enabling `from_utf8`
  • Loading branch information
RalfJung committed Sep 4, 2017
2 parents 9386f05 + 3b6852a commit ee5383f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions miri/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>

let intrinsic_name = &self.tcx.item_name(instance.def_id()).as_str()[..];
match intrinsic_name {
"align_offset" => {
// FIXME: return a real value in case the target allocation has an
// alignment bigger than the one requested
self.write_primval(dest, PrimVal::Bytes(u128::max_value()), dest_ty)?;
},

"add_with_overflow" => {
self.intrinsic_with_overflow(
mir::BinOp::Add,
Expand Down
3 changes: 3 additions & 0 deletions tests/run-pass-fullmir/from_utf8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let _ = ::std::str::from_utf8(b"a");
}

0 comments on commit ee5383f

Please sign in to comment.