On 2023-06-16 13:46, Giuliano Colla via fpc-pascal wrote:
Il 16/06/23 13:36, Peter B via fpc-pascal ha scritto:

Yes. Assigning a 64bit integer to a 32bit one is fine as long as the range is within bounds.
Range of a variable can only be checked at run time.

I can understand that. But the compiler generates quite a number of
warning for potential loss of information. In that case a little
warning wouldn't be excessive, I think.

If you compile with -CO, you should get at least a hint (if you enable displaying them, of course):

---
{$MODE OBJFPC}
uses
 SysUtils;

var
  ISize: Integer;
  SR: TSearchRec;

begin
 FindFirst ('XYZ', faAnyFile, SR);
 ISize := SR.Size;
 WriteLn (ISize);
end.
===

D:\TEMP>fpc -CO -vwih t.pas
Hint: Start of reading config file ...\fpc.cfg
Hint: End of reading config file ...\fpc.cfg
Free Pascal Compiler version 3.2.2 [2021/05/15] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling t.pas
t.pas(11,8) Hint: Type size mismatch, possible loss of data / range check error
Linking t.exe
13 lines compiled, 0.1 sec, 68800 bytes code, 4276 bytes data
3 hint(s) issued

Tomas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to