I have a a program that will read a string and parse the string to some
sub-strings in sub routine.
I add every character to a local string buffer  in sub routine. The code
work well in delphi but suddenly fail in fpc.
When I watch the buffer, it display some garbage instead of null string when
the buffer is untouched.
The following output is supposed to be 1(and it is true here), but in more
complicated situation it is not true. You may get 'bla bla bla 1'.

procedure PrintString;
var str1 : string;
 procedure createContent(var buf : string);
  var str2 :string;
 begin
    buf := str2;
    buf := buf + '1';
 end;

begin
writeln(str1);
end;

My question is we should always assign null string to variable before use or
this a bug if I get garbage in unused string?

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to