Browse Source

* PopCount takes care only of the bit pattern, so take the uvalue to avoid an internal error, resolves #40190

florian 2 years ago
parent
commit
64319dc019
2 changed files with 13 additions and 1 deletions
  1. 2 1
      compiler/nadd.pas
  2. 11 0
      tests/webtbs/tw40190.pp

+ 2 - 1
compiler/nadd.pas

@@ -1833,7 +1833,8 @@ implementation
                       t:=nil;
                       t:=nil;
                       cr:=0;
                       cr:=0;
                     end;
                     end;
-                if (t<>nil) and (PopCnt(cr) = 1) then
+                { using cr.uvalue is fine as we are interested only in the bit pattern }
+                if (t<>nil) and (PopCnt(cr.uvalue) = 1) then
                   begin
                   begin
                     if is_constintnode(taddnode(t).left) then
                     if is_constintnode(taddnode(t).left) then
                       vl:=taddnode(t).left
                       vl:=taddnode(t).left

+ 11 - 0
tests/webtbs/tw40190.pp

@@ -0,0 +1,11 @@
+{ %opt=-O2 }
+{ %norun }
+function InternalInt64ToInt8(Value: Int64; Dest: IntPtr; IgnoreConvertErrors: Boolean): Boolean;
+begin
+  if (Value and $FFFFFFFFFFFFFF80 <> 0) and (Value and $FFFFFFFFFFFFFF80 <> $FFFFFFFFFFFFFF80) then begin
+  // remainder not relevant
+  end;
+end;  
+
+begin
+end.