According to Kevin A. Foss:
[...] It appears that for some reason strings that are defined in procedures/functions are not initialized to a length of 0.
Why should they? Local variables have no predifined value on any Pascal compiler I know.
For example: program test(output);
var a : string (10); begin writeln(length(a)) end.
On both Linux (gpc971001) and OS/2 (gpc980410) I get a result of 0, no problem.
However: program test(output);
var a : string (10);
begin writeln(length(a)); end.
Produces 65536 in OS/2 and 134515920 in Linux.
That was twice the same program, and it produces 0 on my (Linux) system, too. For the sake of compatibility to BP, GPC initializes all global variables to zero/false/nil/empty string.
I'm not sure how much of a bug this is as I'm not sure that the user should assume *anything* about undefined variables.
He shouldn't. Neither in GPC nor in BP which also does not set local strings to length zero (I just checked with BP7).
Greetings,
Peter