[fpc-pascal] Wrong assignment detected only run time without warning
Giuliano Colla
giuliano.colla at fastwebnet.it
Fri Jun 16 12:55:03 CEST 2023
I made a stupid error. My code:
TFileObj = Class(TObject)
[snip]
Size: Integer;
[snip]
end;
....
procedure TForm1.FillDir(FileData : TSearchRec);
...
FFIleObj.Size := FileData.Size;
...
but TSearchRec structure is:
TRawbyteSearchRec = Record
[snip]
Size : Int64;
[snip]
IOW I assign an int64 to an integer.
But when compiling I don't get any warning about that, and when the
program runs there's no problem until the FileData.Size fits into an
integer. When FileData.Size gets too large if compiled with -Co I get a
range exception, if compiled without I just get wrong value for Size.
Is that the intended behavior of compiler?
Platform Linux CentOs 7 - fpc 3.2.2
Giuliano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20230616/32106fc4/attachment.htm>
More information about the fpc-pascal
mailing list