Browse Source

tarraydef.elecount: fix overflow detection

It did not trigger in case of an array[0..high(asizeint)]. Fixes compilation
of webtbs/tw9039[ab] with a compiler built with range checking enabled.
Jonas Maebe 3 years ago
parent
commit
9e7895575e
1 changed files with 3 additions and 1 deletions
  1. 3 1
      compiler/symdef.pas

+ 3 - 1
compiler/symdef.pas

@@ -4469,7 +4469,9 @@ implementation
             result:=0;
             result:=0;
             exit;
             exit;
           end;
           end;
-        if (highrange>0) and (lowrange<0) then
+        { check whether the range might be larger than high(asizeint). Has
+          to include 0..high(sizeint), since that's high(sizeint)+1 elements }
+        if (highrange>=0) and (lowrange<=0) then
           begin
           begin
             qhigh:=highrange;
             qhigh:=highrange;
             if lowrange=low(asizeint) then
             if lowrange=low(asizeint) then