[fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4
Jonas Maebe
jonas at freepascal.org
Tue May 5 22:20:34 CEST 2020
On 05/05/2020 22:05, Rainer Stratmann wrote:
> Compiled with FPC 3.0.4 there is an access violation when executing procvar;
> Compiled with FPC 2.6.4 it works for a long time.
>
> Did I overlooked something?
>
> Mode: MObjFPC
>
> type
> t_funcboolean = function : boolean;
> var
> procvar : t_funcboolean;
>
> function proc_bool : t_funcboolean;
> begin
> end;
>
> begin
> procvar := proc_bool;
This assigns the result of proc_bool to procvar. The result of proc_bool
is not initialised, so you are assigning a random address to procvar.
> procvar; // -> access violation with FPC 3.0.4
That is expected. I don't know why it worked in FPC 2.6.4. Perhaps it
had a bug and assigned the address of proc_bool to procvar, but that is
not the documented behaviour for mode objfpc (it is for mode tp and
delphi though).
Jonas
More information about the fpc-pascal
mailing list