为什么在 x86 中显示 W1022 警告,而在 x64 中却没有?

问题描述 投票:0回答:1

我的delphi是11 Ver.28.0.47991.2819。

当以下简单代码在x64(目标平台64位)中编译时,没有出现警告。 但对于 x86(目标平台 32 位),显示

W1022 Comparison always evaluates to True

变量

a
Unsigned
,所以我觉得在x86中是正确的。 为什么编译 x64 时不显示警告?

procedure TForm1.FormCreate(Sender: TObject);
var
    a : NativeUInt;
begin
    a := 1;
    if ( 0 <= a ) then begin
        Caption := IntToStr( a );
    end;
end;

检查汇编代码时没有什么特别的感觉。

Unit1.pas.73: if ( 0 <= a ) then begin
0000000001142444 48837D3800       cmp qword ptr [rbp+$38],$00
0000000001142449 7227             jb TForm1.FormCreate + $52

谢谢。

delphi 64-bit windows-11 delphi-11-alexandria
1个回答
0
投票

显然,导致 W1022 的检查仅在 32 位序数上执行。将

a
的类型更改为
Cardinal
,您也会在 x64 上收到警告。

© www.soinside.com 2019 - 2024. All rights reserved.