diff options
author | John Hodge <tpg@mutabah.net> | 2018-10-21 12:55:58 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-10-21 12:55:58 +0800 |
commit | ba553fd63c3f88a0eb62dbebe010e50b72fbe8b5 (patch) | |
tree | 33392d6cb9c671d8be148b3aacd7f85cdf329ecf | |
parent | 4d6aa119e76862ba57acc7f99ebf68d1ee71adbd (diff) | |
download | mrust-ba553fd63c3f88a0eb62dbebe010e50b72fbe8b5.tar.gz |
Standalone MIRI - Compilation fixes for 32-bit msvc
-rw-r--r-- | tools/standalone_miri/miri.cpp | 9 | ||||
-rw-r--r-- | tools/standalone_miri/module_tree.cpp | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp index 8231f2c5..14958c45 100644 --- a/tools/standalone_miri/miri.cpp +++ b/tools/standalone_miri/miri.cpp @@ -290,7 +290,12 @@ struct MirHelpers else if( wrapper->type == TypeWrapper::Ty::Array ) { ty = array_ty.get_inner(); - base_val.m_offset += ty.get_size() * idx; + // Check index against array size + if( idx >= wrapper->size ) { + LOG_ERROR("Index out of bounds on array " << array_ty << ", idx=" << idx); + throw "ERROR"; + } + base_val.m_offset += static_cast<size_t>(ty.get_size() * idx); return base_val; } else if( wrapper->type == TypeWrapper::Ty::Slice ) @@ -335,7 +340,7 @@ struct MirHelpers LOG_DEBUG("val = " << val << ", (inner) ty=" << ty); LOG_ASSERT(val.m_size >= POINTER_SIZE, "Deref of a value that doesn't fit a pointer - " << ty); - size_t ofs = val.read_usize(0); + size_t ofs = static_cast<size_t>( val.read_usize(0) ); // TODO: Limits? // There MUST be a relocation at this point with a valid allocation. auto alloc = val.get_relocation(val.m_offset); diff --git a/tools/standalone_miri/module_tree.cpp b/tools/standalone_miri/module_tree.cpp index eb6b6b9e..8e0a231a 100644 --- a/tools/standalone_miri/module_tree.cpp +++ b/tools/standalone_miri/module_tree.cpp @@ -156,12 +156,12 @@ bool Parser::parse_one() auto a = Allocation::new_alloc( reloc_str.size() ); //a.alloc().set_tag(); a->write_bytes(0, reloc_str.data(), reloc_str.size()); - s.val.allocation->relocations.push_back({ ofs, /*size,*/ RelocationPtr::new_alloc(::std::move(a)) }); + s.val.allocation->relocations.push_back({ static_cast<size_t>(ofs), /*size,*/ RelocationPtr::new_alloc(::std::move(a)) }); } else if( lex.next() == "::" || lex.next() == "<" ) { auto reloc_path = parse_path(); - s.val.allocation->relocations.push_back({ ofs, /*size,*/ RelocationPtr::new_fcn(reloc_path) }); + s.val.allocation->relocations.push_back({ static_cast<size_t>(ofs), /*size,*/ RelocationPtr::new_fcn(reloc_path) }); } else { |