From 86bb269d4763f64f957708c1387ef8e008a21b6b Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 11 Aug 2014 20:23:29 +0100 Subject: [PATCH] Fix for GitHub issue #33 - Problem with multi-dimensional arrays. normalize_variable_unpacked() was not correctly calculating the minimum expression width required to calculate the canonical index. --- netmisc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netmisc.cc b/netmisc.cc index f3984e389..ee69e8e6e 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -594,12 +594,12 @@ NetExpr* normalize_variable_unpacked(const NetNet*net, list&indices) // losses. So calculate a min_wid width. unsigned tmp_wid; unsigned min_wid = tmp->expr_width(); - if (use_stride != 1 && ((tmp_wid = num_bits(use_stride)) >= min_wid)) - min_wid = tmp_wid + 1; if (use_base != 0 && ((tmp_wid = num_bits(use_base)) >= min_wid)) min_wid = tmp_wid + 1; if ((tmp_wid = num_bits(dims[idx].width()+1)) >= min_wid) min_wid = tmp_wid + 1; + if (use_stride != 1) + min_wid += num_bits(use_stride); tmp = pad_to_width(tmp, min_wid, *net);