diff --git a/elab_lval.cc b/elab_lval.cc index 659837337..e203c6647 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -25,6 +25,7 @@ # include "compiler.h" # include # include +# include # include "ivl_assert.h" /* @@ -350,7 +351,8 @@ NetAssign_* PEIdent::elaborate_lval_net_word_(Design*des, if (NetEConst*word_const = dynamic_cast(word)) { verinum word_val = word_const->value(); long index = word_val.as_long(); - if (index < 0 || index >= reg->array_count()) { + assert (reg->array_count() <= LONG_MAX); + if (index < 0 || index >= (long) reg->array_count()) { cerr << get_fileline() << ": warning: Constant array index " << (index + reg->array_first()) << " is out of range for array " diff --git a/vvp/vpi_memory.cc b/vvp/vpi_memory.cc index 6a58afe99..efcae4e8e 100644 --- a/vvp/vpi_memory.cc +++ b/vvp/vpi_memory.cc @@ -225,10 +225,11 @@ static vpiHandle memory_word_put(vpiHandle ref, p_vpi_value val) /* Addresses are converted to canonical form by offsetting the address by the lowest index. */ - unsigned addr_off = memory_left_range(rfp->mem->mem, 0); + long addr_off = memory_left_range(rfp->mem->mem, 0); if (memory_right_range(rfp->mem->mem, 0) < addr_off) addr_off = memory_right_range(rfp->mem->mem, 0); + assert(addr_off >= 0 && (unsigned) addr_off <= word_addr); word_addr -= addr_off; /* Build up the word value from whatever format the user