Hello,
When compiling a Pascal source with gpc, I receive the following warning:
gpc -g -O0 -D_DEBUG --setlimit=2000 --unit-path=gpi:gpc --gpi-destination-path=gpi --implementation-only -D_DBG -Icommon/include -Imain/include -I/data2/informix-7.31.UD6/include -I/data2/informix-7.31.UD6/incl/esql -I/usr/local/devapps/ISAM/include -c common/src/fdb.pas -o obj/dbg/fdb.o common/src/fdb.pas: In procedure `CreeFDB': common/src/fdb.pas:1041: warning: `for' loop counter is threatened in a subroutine
And here is the code that triggers the warning:
FOR I := PosARec TO NbChamps DO BEGIN IF ((Champs[I].TipeNb > 1) AND (I <> PosARec)) THEN BEGIN WRITELN('Error: Array in an Array of Records! (line:', Line,')'); RETURN; END; Champs[I].Pos := Champs[I].Pos + AjusARec; Champs[I].TipeNb := TipeNb; Champs[I].DifByte := NbByteARec; END;
The code inside the 'for' loop does not call any subroutine, except WriteLn and Return (conditionally) and they don't make any use of the counter. I wonder how the loop counter may be threatened in any way... My question is: did I missed something, or is gpc so delicate that one cannot use a 'for' loop counter outside of the loop for other purpose (that's the case here, the 'for' loop in the middle of a procedure)? How gpc determines that a 'for' loop counter may be altered in the body of the loop?
Thanks
Pascal Viandier
pascal@accovia.com