Fix bug in checking array ranges.
authorMario de Sousa <msousa@fe.up.pt>
Thu, 30 Aug 2012 13:08:02 +0100
changeset 647 99b45154eb2c
parent 646 dd76ce4a7e22
child 648 5ca2aabb8bcb
Fix bug in checking array ranges.
configure
stage3/array_range_check.cc
--- a/configure	Thu Aug 30 13:06:54 2012 +0100
+++ b/configure	Thu Aug 30 13:08:02 2012 +0100
@@ -4613,7 +4613,8 @@
 
 
 # Check bison version, we need a version great or equal than 2.4 to build matiec.
-[[ $(bison --version) =~ ([0-9][.][0-9]*) ]] && version_bison="${BASH_REMATCH[1]}"
+version_bison="$(bison --version | sed q | cut -d' ' -f4)"
+version_bison=${version_bison:0:3}
 
 if awk -v ver="$version_bison" 'BEGIN { if (ver < 2.4) exit 1; }'; then :
   have_bison_correct=yes
--- a/stage3/array_range_check.cc	Thu Aug 30 13:06:54 2012 +0100
+++ b/stage3/array_range_check.cc	Thu Aug 30 13:08:02 2012 +0100
@@ -161,7 +161,7 @@
       {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (should be <= %"PRIu64").", GET_CVALUE(uint64, dimension->upper_limit)); continue;}
       
     if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit))
-      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)) < 0 )
+      if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)) > 0 )
       {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds (should be <= %"PRId64").", GET_CVALUE( int64, dimension->upper_limit)); continue;}
       
   }