On Sun, 27 Dec 2020, Graeme Geldenhuys via fpc-pascal wrote:
Hi, Is this a bug in FPC 3.2.0 where TCustomStream still uses LongInt in the Read() method, where all other methods in in the class uses Int64 type? Here is the FPC code: TCustomMemoryStream = class(TStream) private FMemory: Pointer; FSize, FPosition: PtrInt; protected Function GetSize : Int64; Override; function GetPosition: Int64; Override; procedure SetPointer(Ptr: Pointer; ASize: PtrInt); public function Read(var Buffer; Count: LongInt): LongInt; override; // <-- Here function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; ... end; As this class extends the TStream class, I guess the issue relates to TStream too. eg: Why would you have GetSize(): Int64; or GetPosition: Int64; but when you read data, it is limited to the Longint type?
Because on 32 bit platforms, this is the maximum size of available memory for a program, and we like things maximally portable. You can't read more than 2gb in memory on a 32-bit platform. Seek, Size and position must support 64-bit, since the size of a file on disk can of course be bigger than what 32-bit allows. Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal