Running the following code in Delphi 12 results to an exception. In FPC 3.2 gives a negative number.
var m:integer; n:cardinal;
begin n:=high(cardinal);
m:=n;
if m<0 then showmessage('negative');
end;
The following code runs without exceptions and some results in both Delphi 12 & FPC 3.2
var m:integer; n:cardinal;
begin n:=high(cardinal);
m:=integer(n);
if m<0 then showmessage('negative');
end;
To my way of thinking Delphi does it well. A Cardinal can not always fit to an integer. To force it to fit in the memory, it has now an other number that it is negative (-1).
In the second case, the programmer wants a conversion and is aware of the possible results.
What is your opinion?