I'm not sure what the correct behaviour should be in the attached program, but GPC's behaviour is different from the previous extended Pascal compiler I used (I'm not saying that the previous compiler was right).
The previous compiler allowed one to write to a text file that had been opened with 'reset' and then 'extend'ed. GPC says:
./daj13: cannot write to read only file `daj13.pas' (error #422)
===== program daj13(input,output);
var f:text;
begin reset(f,'daj13.pas'); extend(f); writeln(f,'extra text'); end.