summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-11-24 14:48:37 +0800
committerJohn Hodge <tpg@mutabah.net>2018-11-24 14:48:37 +0800
commit3ed852f30e6b039050b44e2b89010215332b7bac (patch)
treed64c1579de86dc1af4faec1e1221811313b35c41
parent61d7669269529ea65a7dc797c0db2f84a05fc7b8 (diff)
downloadmrust-3ed852f30e6b039050b44e2b89010215332b7bac.tar.gz
standalone_miri - Fix MSVC ice and clean up some warnings
-rw-r--r--tools/standalone_miri/miri.cpp4
-rw-r--r--tools/standalone_miri/value.cpp10
2 files changed, 7 insertions, 7 deletions
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp
index 53783420..fd4d45d8 100644
--- a/tools/standalone_miri/miri.cpp
+++ b/tools/standalone_miri/miri.cpp
@@ -363,7 +363,7 @@ struct MirHelpers
size_t slice_inner_size;
if( ty.has_slice_meta(slice_inner_size) ) {
- size = (ty.get_wrapper() == nullptr ? ty.get_size() : 0) + meta_val->read_usize(0) * slice_inner_size;
+ size = (ty.get_wrapper() == nullptr ? ty.get_size() : 0) + static_cast<size_t>(meta_val->read_usize(0)) * slice_inner_size;
}
//else if( ty == RawType::TraitObject) {
// // NOTE: Getting the size from the allocation is semi-valid, as you can't sub-slice trait objects
@@ -1036,7 +1036,7 @@ bool InterpreterThread::step_one(Value& out_thread_result)
LOG_ASSERT(ty_r.get_wrapper() == nullptr, "Bitwise operator with non-primitive - " << ty_r);
size_t max_bits = ty_r.get_size() * 8;
uint8_t shift;
- auto check_cast = [&](auto v){ LOG_ASSERT(0 <= v && v <= static_cast<decltype(v)>(max_bits), "Shift out of range - " << v); return static_cast<uint8_t>(v); };
+ auto check_cast = [&](uint64_t v){ LOG_ASSERT(0 <= v && v <= static_cast<decltype(v)>(max_bits), "Shift out of range - " << v); return static_cast<uint8_t>(v); };
switch(ty_r.inner_type)
{
case RawType::U64: shift = check_cast(v_r.read_u64(0)); break;
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp
index 39b3b906..5974a172 100644
--- a/tools/standalone_miri/value.cpp
+++ b/tools/standalone_miri/value.cpp
@@ -214,8 +214,8 @@ void* ValueCommonRead::read_pointer_unsafe(size_t rd_ofs, size_t req_valid, size
LOG_FATAL("Out-of-bounds pointer");
if( ofs + req_valid > a.size() )
LOG_FATAL("Out-of-bounds pointer (" << ofs << " + " << req_valid << " > " << a.size());
- a.check_bytes_valid( ofs, req_valid );
- out_size = a.size() - ofs;
+ a.check_bytes_valid( static_cast<size_t>(ofs), req_valid );
+ out_size = a.size() - static_cast<size_t>(ofs);
out_is_mut = true;
return a.data_ptr() + ofs;
}
@@ -225,7 +225,7 @@ void* ValueCommonRead::read_pointer_unsafe(size_t rd_ofs, size_t req_valid, size
LOG_FATAL("Out-of-bounds pointer");
if( ofs + req_valid > s.size() )
LOG_FATAL("Out-of-bounds pointer (" << ofs << " + " << req_valid << " > " << s.size());
- out_size = s.size() - ofs;
+ out_size = s.size() - static_cast<size_t>(ofs);
out_is_mut = false;
return const_cast<void*>( static_cast<const void*>(s.data() + ofs) );
}
@@ -237,7 +237,7 @@ void* ValueCommonRead::read_pointer_unsafe(size_t rd_ofs, size_t req_valid, size
//if( req_valid )
// LOG_FATAL("Can't request valid data from a FFI pointer");
// TODO: Have an idea of mutability and available size from FFI
- out_size = f.size - ofs;
+ out_size = f.size - static_cast<size_t>(ofs);
out_is_mut = false;
return reinterpret_cast<char*>(reloc.ffi().ptr_value) + ofs;
}
@@ -256,7 +256,7 @@ ValueRef ValueCommonRead::read_pointer_valref_mut(size_t rd_ofs, size_t size)
else
{
// TODO: Validate size
- return ValueRef(reloc, ofs, size);
+ return ValueRef(reloc, static_cast<size_t>(ofs), size);
}
}