From f47af361cdb76a460e4bf44d616fac05a8febb07 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 20 Nov 2013 16:48:15 -0800 Subject: [PATCH] For default function arguments do not access an out of range real argument. The code should only look at the real argument that exist any missing arguments default to not being defined and hence needs to use the default expression. Found with valgrind. --- elab_expr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elab_expr.cc b/elab_expr.cc index 53041e324..d8f6ac313 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -2145,10 +2145,11 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope, unsigned missing_parms = 0; const unsigned parm_count = parms.size() - parm_off; + const unsigned actual_count = parms_.size(); for (unsigned idx = 0 ; idx < parm_count ; idx += 1) { unsigned pidx = idx + parm_off; - PExpr*tmp = parms_[idx]; + PExpr*tmp = (idx < actual_count) ? parms_[idx] : 0; if (tmp) { parms[pidx] = elaborate_rval_expr(des, scope, def->port(pidx)->net_type(),