[fpc-devel] Internal error in FPC 2.6.0rc1

Sergei Gorelkin sergei_gorelkin at mail.ru
Fri Nov 25 13:49:48 CET 2011


25.11.2011 13:36, Michael Müller пишет:
> Hi,
>
> I tested RC1 using one of my codes and ran into an internal error. I was able to reduce the code to the following.
>
> Free Pascal Compiler version 2.6.0rc1 [2011/10/15] for i386
> Copyright (c) 1993-2011 by Florian Klaempfl and others
> Target OS: Win32 for i386
> Compiling InternalError.dpr
> InternalError.dpr(21,3) Fatal: Internal error 201103063
> Fatal: Compilation aborted
>
> --- Code, start ---
>
> {$IFDEF FPC}
>    {$MODE Delphi}
> {$ENDIF}
>
> program InternalError;
>
> procedure SetArray({var}out SingleArray: array of Single; const Value: Single);
> var
>    I: Integer;
> begin
>    for I := Low(SingleArray) to High(SingleArray) do
>      SingleArray[I] := Value;
> end;
>
> var
>    ValuesBuffer: array of Single;
>
> begin
>    SetLength(ValuesBuffer, 5);
>    SetArray(ValuesBuffer, 5.7);
> end.
>
> --- Code, end ---
>
> The error is at the beginning of SetArray() call.
>
I guess this one is for me to fix.

> I see that the real error is in my code since the procedure parameter has to be 'var' and not 'out' otherwise the dimension which is set outside will not reach the procedure. But the compiler shouldn't stop with an internal error. If it is changed to 'var' it compiles.
>
Frankly speaking, I doubt that. 'out' in this case likely refers to elements of dynamic array, not 
to array itself. If it was e.g. 'array of ansistring' then all its elements should be finalized 
before the call, then pointer to first element and length passed to callee.


 > FPC 2.4.4 just compiles it.

But it may produce incorrect code when managed types are involved, see 
http://bugs.freepascal.org/view.php?id=18859

Regards,
Sergei







More information about the fpc-devel mailing list