[fpc-pascal] Result: string
José Mejuto
joshyfun at gmail.com
Wed Mar 6 13:37:44 CET 2013
El 06/03/2013 10:40, Jonas Maebe escribió:
> FPC 2.6.2 does give a warning (code is from
> http://bugs.freepascal.org/view.php?id=20907#c55064 ):
[...]
> It could also fail in 2.6.x, just less often.
Hello,
2.6.0, 2.6.2 and 2.7.1 trunk produces a warning with that code, but with
this one 2.6.0, and 2.7.1 trunk does not generate it (I do not have
2.6.2 to test):
>\fpc\svn\bin\i386-win32\fpc test.pp
Free Pascal Compiler version 2.7.1 [2013/03/03] for i386
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pp
Linking test.exe
26 lines compiled, 0.1 sec, 29680 bytes code, 1236 bytes data
>\fpc\fpc\2.6.0\bin\i386-win32\fpc.exe test.pp
Free Pascal Compiler version 2.6.0 [2011/12/25] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pp
Linking test.exe
26 lines compiled, 0.0 sec , 27264 bytes code, 1692 bytes data
----------------------------------
program test;
{$mode objfpc}
{$h+}
procedure TheB(var aTheA: string);
begin
aTheA:=aTheA+'A';
end;
function TheA(): string;
begin
TheB(Result);
end;
Var
C : String;
begin
C:='B';
C:=TheA;
C:=TheA;
Writeln('= "',C,'"');
end.
-----------------------------------
And the effect is the same as using a non initialized variable, so it
must generate a warning AFAIK. So passing Result as var does not
generate a warning.
--
More information about the fpc-pascal
mailing list