
{: test that accessing argv with out of bounds index causes a fatal error }

{d+}
program d1021( output );

var
   s : packed array[1..50] of char;
   k : integer;

function side: integer;
begin
   side := k;
   k := k+1;
end; { side }

begin {d1021}

   k := 0;
   argv(side, s );
   writeln( 'argv[0] is ', s, ' INFO' );
   if k <> 1 then
      writeln( 'argv has side effects' );

   argv( argc, s ); {!!! arg index is 0..argc-1 }

   writeln( 'fails: out of bounds arg index not detected' );
end. { d1021 }

