[fpc-devel] Question about hint in bool eval / Mixing signed expressions and longwords gives a 64bit result

Martin lazarus at mfriebe.de
Tue Jan 8 09:46:20 CET 2013


I know it's a hint. And I know that implies it may mean noting, and yet 
is still present....
Just trying to understand.
if I did "int-longword" (same for addition and reverse order) then I 
need a int64 to hold the result.

--- 1)
Yet on my 32 bit Win vista (testing with  2.7.1 [2012/12/09] for i386 )
     fpc.exe  -MObjFPC -Scghi -O1 -g -gl -vewnhi  -l project1.lpr

This gives no hint or warning (ignoring the "uninitialized" ones). It 
still gives none, even if I add " -Cro "

program Project1;
var
   a: LongWord;
   b: Integer;
begin
   b := a - b;  // (+$ffffffff) - ( -$7fffffff ) => can not be hold in 
"b" integer
   b := b - a;
end.

Given that this may actually truncate data (or give a run-error), IMHO a 
warning would be ok.

--- 2)
But then, if I compare the 2 values, resulting in a boolean value (no 
risk of data truncation), then I get the hint
project1.lpr(7,10) Hint: Mixing signed expressions and longwords gives a 
64bit result

program Project1;
var
   a: LongWord;
   b: Integer;
   c: Boolean;
begin
   c := a < b;
end.

In this case, I don't even see why a hint is needed? (I might overlook 
something).




More information about the fpc-devel mailing list