According to The African Chief:
[...] Why does the following program behave differently under BP and GPC? [...] StrDispose(p1); if assigned(p1) then p2 := strnew(p1); Writeln(p2); {GPC writes the full string; BP writes "Fred"}
If `StrDispose' does what the name promises, `writeln ( p2 )' should produced *undefined* behaviour.
Since BP writes "Fred" instead of producing a runtime error, BP obviously passes `p1' by *value* just like GPC.
Since `p1' is a *pointer* to the actual chars, the *string* is always passed by reference - both in BP and in GPC.
StrDispose(p2); StrDispose(p2); {should cause a runtime error - but doesn't under GPC}
This is incorrect, indeed. After the first `Dispose', the pointer should have an undefined value, so the second `Dispose' normally should crash. But in fact is is also correct "undefined" behaviour simply to ignore the second `Dispose' ...
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [971005] maintainer GNU Pascal [971001] - http://home.pages.de/~gnu-pascal/ [971005]