On Mon, 12 Nov 2001, CBFalconer wrote:
--mirsad05.pas------------------------------------------------------------ PROGRAM setranges5(output); { Written by: Mirsad Todorovac Nov 2001; copying by GPL. ------------------------------------------------------------ Stresses setrange construction and adding; checks if there's more in SET than we've put in. lasts few seconds where I've tested it.} CONST maxN = 255; VAR seta, setb, setc: SET OF 0..maxN; i, j, len, start, endr: Cardinal; failed: Boolean = false;
BEGIN FOR i:= 0 TO maxN DO IF ((i IN seta) OR (i IN setb) OR (i IN setc)) THEN writeln('Failed: SET not initialized empty!');
There is no automatic initialization in Pascal, without some sort of extension. Thus this test is not valid.
I admit my error: I used default behavior spotted on available systems as a standard, which doesn't have to be true. As Frank said in other message, we can modify test by adding explicit initialization to SET decl.
However, maybe there should be a third result of a test, 'warning'; which would test non-portable behavior?
And second, shouldn't compiler *WARN* me about accessing the value of non-initialized variable with IN operator? I've tried and even with -Wall gpc was quiet.
mirsad
-- This message has been made up using recycled ideas and language constructs. No plant or animal has been injured in process of making this message.