[fpc-devel] mising ansi string ref increase

Florian Klaempfl florian at freepascal.org
Thu Jul 22 08:49:22 CEST 2010


Am 22.07.2010 05:06, schrieb Martin:
> Ok I reproduced it. (compiled  with -gh -gt -O1 => but I am not sure it
> matters
> 
> Question: Is it some wrong doing of me? or shall i report it as bug?
> 
> In Foo, "s" is supposed to be a copy of "x" => the string should have a
> ref count of 2, and the modification of x, should make a copy of the
> string.
> afaik the output should be "a" => but it is "X"
> 
> You can also set x:='' => which will be random in output
> 
> program Project1;
> 
> {$mode objfpc}{$H+}
> 
> var
>   x: String;
> 
> procedure Foo(const s: String);
> begin
>   x[1]:='X';  //  x:='';
>   writeln(s);
> end;

This should not compile. The string is declared const, please fill a bug
report.



More information about the fpc-devel mailing list