ソースを参照

* fixed overflow for constant in-expressions involving values >
high(uinttype) on the left side

git-svn-id: trunk@6852 -

Jonas Maebe 18 年 前
コミット
f63b0ef160
1 ファイル変更11 行追加2 行削除
  1. 11 2
      compiler/nset.pas

+ 11 - 2
compiler/nset.pas

@@ -286,8 +286,17 @@ implementation
            begin
              if (right.nodetype=setconstn) then
                begin
-                 t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
-                   booltype,true);
+                 { tordconstnode.value is int64 -> signed -> the expression }
+                 { below will be converted to longint on 32 bit systems due }
+                 { to the rule above -> will give range check error if      }
+                 { value > high(longint) if we don't take the signedness    }
+                 { into account                                             }
+                 if is_signed(left.resultdef) then
+                   t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
+                     booltype,true)
+                 else
+                   t:=cordconstnode.create(byte(TConstExprUInt(tordconstnode(left).value) in Tsetconstnode(right).value_set^),
+                     booltype,true);                   
                  typecheckpass(t);
                  result:=t;
                  exit;