Handle out-of-bounds and undefined word indices in constant functions.

This commit is contained in:
Martin Whitaker 2013-05-18 19:39:24 +01:00
parent 26dc6d68cd
commit 9a69fcff7b
1 changed files with 4 additions and 1 deletions

View File

@ -193,6 +193,9 @@ bool NetAssign::eval_func_lval_(const LineInfo&loc,
NetEConst*word_const = dynamic_cast<NetEConst*>(word_result);
ivl_assert(loc, word_const);
if (!word_const->value().is_defined())
return true;
word = word_const->value().as_long();
if (word >= ptr->second.nwords)
@ -683,7 +686,7 @@ NetExpr* NetESignal::evaluate_function(const LineInfo&loc,
unsigned word = word_const->value().as_long();
if (word < ptr->second.nwords)
if (word_const->value().is_defined() && (word < ptr->second.nwords))
value = ptr->second.array[word];
} else {
value = ptr->second.value;