My delphi is 11 Ver.28.0.47991.2819.
When the below simple code was compiled in x64 (Target platform 64bit), no warning occurred.
But for x86 (Target platform 32bit), shows W1022 Comparison always evaluates to True
.
Variable a
is Unsigned
, so I feel it's correct in the x86 one.
Why is the warning not shown while compiling for x64?
procedure TForm1.FormCreate(Sender: TObject);
var
a : NativeUInt;
begin
a := 1;
if ( 0 <= a ) then begin
Caption := IntToStr( a );
end;
end;
I feel nothing special while checking assembly code.
Unit1.pas.73: if ( 0 <= a ) then begin
0000000001142444 48837D3800 cmp qword ptr [rbp+$38],$00
0000000001142449 7227 jb TForm1.FormCreate + $52
Thanks.
Apparently, the check leading to the W1022 is only performed on 32-bit ordinals. Change the type of a
to Cardinal
and you get the warning also on x64.