From 831b6d3ad6e1a9537c9de5b84b526cd1d43f6a0d Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 12 Dec 2011 23:02:09 +0000 Subject: [PATCH] Fix for crash when real value assigned to signed type parameter. A declaration of the form "parameter signed a = 1.0" causes a compiler crash. The standard is somewhat contradictory on what type "a" should have, but testing with other compilers shows a majority in favour of it being a real value. --- net_design.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net_design.cc b/net_design.cc index 6a9ebe386..84f4a7a34 100644 --- a/net_design.cc +++ b/net_design.cc @@ -409,7 +409,7 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) sure the type is set right. Note that if the parameter doesn't have an explicit type or range, then it will get the signedness from the expression itself. */ - if ((*cur).second.signed_flag || range_flag) { + if (range_flag) { /* If we have a real value convert it to an integer. */ if(NetECReal*tmp = dynamic_cast(expr)) { verinum nval(tmp->value().as_long64(), (unsigned)lv_width); @@ -419,6 +419,8 @@ void NetScope::evaluate_parameter_logic_(Design*des, param_ref_t cur) } (*cur).second.val->cast_signed((*cur).second.signed_flag); + } else if ((*cur).second.signed_flag) { + (*cur).second.val->cast_signed(true); } // If there are no value ranges to test the value against,