From 1ee6c490283a11ff796b8a7dfe91390a3955cc6a Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Tue, 2 Jun 2020 15:46:37 +0200 Subject: [PATCH] Adding fixes for signedness warnings in test/tools/yulInterpreter --- test/tools/yulInterpreter/EVMInstructionInterpreter.cpp | 8 ++++---- test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp | 6 +++--- test/tools/yulInterpreter/Interpreter.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index d60b63b10..9c46ea856 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -48,10 +48,10 @@ u256 readZeroExtended(bytes const& _data, u256 const& _offset) if (_offset >= _data.size()) return 0; else if (_offset + 32 <= _data.size()) - return *reinterpret_cast(_data.data() + size_t(_offset)); + return *reinterpret_cast(_data.data() + static_cast(_offset)); else { - size_t off = size_t(_offset); + size_t off = static_cast(_offset); u256 val; for (size_t i = 0; i < 32; ++i) { @@ -88,7 +88,7 @@ u256 EVMInstructionInterpreter::eval( using evmasm::Instruction; auto info = instructionInfo(_instruction); - yulAssert(size_t(info.args) == _arguments.size(), ""); + yulAssert(static_cast(info.args) == _arguments.size(), ""); auto const& arg = _arguments; switch (_instruction) @@ -442,7 +442,7 @@ u256 EVMInstructionInterpreter::evalBuiltin(BuiltinFunctionForEVM const& _fun, c m_state.memory, m_state.code, size_t(_arguments.at(0)), - size_t(_arguments.at(1) & size_t(-1)), + size_t(_arguments.at(1) & numeric_limits::max()), size_t(_arguments.at(2)) ); } diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index e4c190e9c..b523e7efe 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -87,9 +87,9 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a copyZeroExtended( m_state.memory, m_state.code, - size_t(_arguments.at(0)), - size_t(_arguments.at(1) & size_t(-1)), - size_t(_arguments.at(2)) + static_cast(_arguments.at(0)), + static_cast(_arguments.at(1) & numeric_limits::max()), + static_cast(_arguments.at(2)) ); return 0; } diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index 6f989b873..5f0861d14 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -54,7 +54,7 @@ void InterpreterState::dumpTraceAndState(ostream& _out) const _out << "Memory dump:\n"; map words; for (auto const& [offset, value]: memory) - words[(offset / 0x20) * 0x20] |= u256(uint32_t(value)) << (256 - 8 - 8 * size_t(offset % 0x20)); + words[(offset / 0x20) * 0x20] |= u256(uint32_t(value)) << (256 - 8 - 8 * static_cast(offset % 0x20)); for (auto const& [offset, value]: words) if (value != 0) _out << " " << std::uppercase << std::hex << std::setw(4) << offset << ": " << h256(value).hex() << endl;