@@ -21,25 +21,25 @@ constexpr auto word_size = 32;
2121
2222// / Returns number of words what would fit to provided number of bytes,
2323// / i.e. it rounds up the number bytes to number of words.
24- constexpr int64_t num_words (size_t size_in_bytes) noexcept
24+ constexpr int64_t num_words (uint64_t size_in_bytes) noexcept
2525{
2626 return (static_cast <int64_t >(size_in_bytes) + (word_size - 1 )) / word_size;
2727}
2828
29- inline bool check_memory (execution_state& state, const uint256& offset, int64_t size) noexcept
29+ inline bool check_memory (execution_state& state, const uint256& offset, uint64_t size) noexcept
3030{
3131 if (offset > max_buffer_size)
3232 {
3333 state.exit (EVMC_OUT_OF_GAS);
3434 return false ;
3535 }
3636
37- const auto new_size = static_cast <int64_t >(offset) + size;
38- const auto current_size = static_cast < int64_t >( state.memory .size () );
37+ const auto new_size = static_cast <uint64_t >(offset) + size;
38+ const auto current_size = state.memory .size ();
3939 if (new_size > current_size)
4040 {
4141 const auto new_words = num_words (new_size);
42- const auto current_words = current_size / 32 ; // Memory always has full words.
42+ const auto current_words = static_cast < int64_t >( current_size / 32 );
4343 const auto new_cost = 3 * new_words + new_words * new_words / 512 ;
4444 const auto current_cost = 3 * current_words + current_words * current_words / 512 ;
4545 const auto cost = new_cost - current_cost;
@@ -68,7 +68,7 @@ inline bool check_memory(
6868 return false ;
6969 }
7070
71- return check_memory (state, offset, static_cast <int64_t >(size));
71+ return check_memory (state, offset, static_cast <uint64_t >(size));
7272}
7373
7474
@@ -144,7 +144,8 @@ void op_exp(execution_state& state, instr_argument) noexcept
144144 const auto base = state.stack .pop ();
145145 auto & exponent = state.stack .top ();
146146
147- const auto exponent_significant_bytes = intx::count_significant_words<uint8_t >(exponent);
147+ const auto exponent_significant_bytes =
148+ static_cast <int >(intx::count_significant_words<uint8_t >(exponent));
148149 const auto exponent_cost = state.rev >= EVMC_SPURIOUS_DRAGON ? 50 : 10 ;
149150 const auto additional_cost = exponent_significant_bytes * exponent_cost;
150151 if ((state.gas_left -= additional_cost) < 0 )
0 commit comments