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 /tools/standalone_miri/miri.cpp | |
parent | 4d6aa119e76862ba57acc7f99ebf68d1ee71adbd (diff) | |
download | mrust-ba553fd63c3f88a0eb62dbebe010e50b72fbe8b5.tar.gz |
Standalone MIRI - Compilation fixes for 32-bit msvc
Diffstat (limited to 'tools/standalone_miri/miri.cpp')
-rw-r--r-- | tools/standalone_miri/miri.cpp | 9 |
1 files changed, 7 insertions, 2 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); |