I don't know when and why this changed but I have the same issue (Delphi 2007). it appears that ReadTIdBytesFromStream is expecting an int64 (TIdStreamSize) to be passed as the Count parameter but the variable being passed (LBufSize) is an integer.
This appears to cause the complier considerable problems and it throws an internal error. I browsed around the Indy code until I found other examples of this function call that generated no errors.
I found this snippet of code in the TIdHashIntf.GetHashBytes method and borrowed from it
repeat
LSize := ReadTIdBytesFromStream(AStream,LBuf,IndyMin(ASize, 2048));
I then changed the code in ReadLnFromStream from this:
repeat
LBufSize := IndyMin(LStrmSize - LStrmPos, LBUFMAXSZE);
LBufSize := ReadTIdBytesFromStream(AStream, LBuf, LBufSize);
to this
repeat
LBufSize := ReadTIdBytesFromStream(AStream, LBuf, IndyMin(LStrmSize - LStrmPos, LBUFMAXSIZE));
And now Indy builds and complies again.
As far as I can tell this change will not effect anything (apart from fixing the broken build), but I can appreciate it is a bit of a WTF. Without going deep into the reasons as to why some variables are int, others int64 and yet others are TIdStreamSize, this is the best I can do. Maybe Remy could enlighten us all.
Incidentally I noticed if complied in debug mode the fatal complier error did not occur.
LBufSize := IndyMin(LStrmSize - LStrmPos, LBUFMAXSIZE);
The line you quoted is line 8634 instead. So which line is the actual problem? The only thing I can think of is that both lines do involve Integer<->Int64 conversions, but I can't imagine the compiler choking on that, especially if it was working previously. - Remy LebeauIdGlobal.pas
in the past 2 months (mostly in preparation for iOS 64bit), none of the changes should be affectingReadLnFromStream()
like this. But this is an internal error, which means anything could potentially be putting the compiler into a bad state even before it reachesReadLnFromStream()
. I don't have D2007 installed, so I can't troubleshoot the problem myself. If you can narrow down a fix, you can send it to me for checkin. - Remy LebeauLBufSize := IndyMin(LStrmSize - LStrmPos, LBUFMAXSIZE);
to this:LBufSize := Integer(IndyMin(LStrmSize - LStrmPos, LBUFMAXSIZE));
? Or changeReadTIdBytesFromStream()
to useInteger
instead ofTIdStreamSize
? - Remy LebeauTIdStreamSize
isInt64
in D6+. A dynamic array usesNativeInt
for its length and indexing, soInteger
on 32-bit systems andInt64
on 64-bit systems. ButTStream.Read()
usesLongint
for its byte count andLongint
is 32-bit on most platforms (iOS 64bit is changing that). So maybeReadLnFromStream()
needs to declareLBufSize
asNativeInt
to match the RTL and avoid unnecessary conversions, even though only 2K are being read at a time? I see some other functions in IdGlobal that are usingTIdStreamSize
whereNativeInt
might make more sense. - Remy Lebeau