[fpc-pascal] Result: string

Michael Van Canneyt michael at freepascal.org
Tue Mar 5 11:27:40 CET 2013



On Tue, 5 Mar 2013, Howard Page-Clark wrote:

> On 04/03/13 10:33, José Mejuto wrote:
>
>> The code that makes me wonder something is wrong is this one:
>> 
>> -----------------------------------
>> {$mode objfpc}
>> {$h+}
>> 
>> procedure TheB(var aTheA: string);
>> 
>> begin
>>    aTheA:=aTheA+'A';
>> end;
>> 
>> function TheA(): string;
>> 
>> begin
>>    //Result:='';
>>    TheB(Result);
>> end;
>> 
>> Var
>>    C : String;
>> 
>> begin
>>    C:='B';
>>    C:=TheA;
>>    C:=TheA;
>>    Writeln('= "',C,'"');
>> end.
>
> For me (win32, FPC 2.6.2) the output is identical (= "A") whether or not 
> Result in TheA() is initialised manually or not. Perhaps 2.7.1 has a 
> regression here if it differs for you?

It is not a regression. 2.7.1 has the Delphi compatible behaviour.

Michael.


More information about the fpc-pascal mailing list