Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-05

Different behaviour between FPC 2.6.4 and FPC 3.0.4

12 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann
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;
 procvar; // -> access violation with FPC 3.0.4

Reply by email

Alexander Grotewohl
to Rainer Stratmann

; ?

Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 28 lines
From: fpc-pascal on behalf of Rainer Stratmann Sent: Tuesday, May 5, 2020, 4:05 PM To: FPC-Pascal users discussions Subject: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 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; procvar; // -> access violation with FPC 3.0.4

Reply by email

Rainer Stratmann
to Alexander Grotewohl
Alexander Grotewohl wrote
; ?

Error: Incompatible types

Show quoted text 37 lines
-- Alexander Grotewohl https://dcclost.com ________________________________ From: fpc-pascal on behalf of Rainer Stratmann Sent: Tuesday, May 5, 2020, 4:05 PM To: FPC-Pascal users discussions Subject: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 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; procvar; // -> access violation with FPC 3.0.4 _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to Rainer Stratmann: Compiled with FPC 3.0.4 there is an access violation when executing procvar; Compiled…
Rainer Stratmann wrote 18 lines
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

Reply by email

Alexander Grotewohl
to Rainer Stratmann: Error: Incompatible types

my original suggestion and then

function proc_bool : boolean;

what exactly are you trying to accomplish?

Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 51 lines
From: fpc-pascal on behalf of Rainer Stratmann Sent: Tuesday, May 5, 2020 4:20:11 PM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 Am Dienstag, 5. Mai 2020, 22:14:09 CEST schrieb Alexander Grotewohl: > ; ? Error: Incompatible types > -- > Alexander Grotewohl > https://dcclost.com > > ________________________________ > From: fpc-pascal on behalf of > Rainer Stratmann Sent: Tuesday, May 5, 2020, > 4:05 PM > To: FPC-Pascal users discussions > Subject: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 > > 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; > procvar; // -> access violation with FPC 3.0.4 > > > > > _______________________________________________ > fpc-pascal maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Rainer Stratmann
to Alexander Grotewohl

YES that works, thank you!

Alexander Grotewohl wrote 63 lines
my original suggestion and then function proc_bool : boolean; what exactly are you trying to accomplish? -- Alexander Grotewohl https://dcclost.com ________________________________ From: fpc-pascal on behalf of Rainer Stratmann Sent: Tuesday, May 5, 2020 4:20:11 PM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 Am Dienstag, 5. Mai 2020, 22:14:09 CEST schrieb Alexander Grotewohl: > ; ? Error: Incompatible types > -- > Alexander Grotewohl > https://dcclost.com > > ________________________________ > From: fpc-pascal on behalf of > Rainer Stratmann Sent: Tuesday, May 5, 2020, > 4:05 PM > To: FPC-Pascal users discussions > Subject: [fpc-pascal] Different behaviour between FPC 2.6.4 and FPC 3.0.4 > > 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; > procvar; // -> access violation with FPC 3.0.4 > > _______________________________________________ > fpc-pascal maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Rainer Stratmann
to Bart
Bart wrote 7 lines
On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann wrote: > Did I overlooked something? Your function returns a functiontype? Is that intended?

No :-)
But that worked a long time (2 years or so) with FPC 2.6.4

procvar points either to a library function or to a default function.

In case of the shown example it was the default function.

May be a pointer to zero was not executed in FPC 2.6.4 because it does not make sense. And in FPC 3.0.4 the compiled program executes a pointer to zero (nil). Or similar.

Anyway it runs well now. Thanks!

Show quoted text 5 lines
-- Bart _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Rainer Stratmann
to Bart: On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann Your function returns a functiontype? Is…
Bart wrote 7 lines
On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann wrote: > Did I overlooked something? Your function returns a functiontype? Is that intended?

And I wonder why
result := false;
did not work in this function :-)

Show quoted text 5 lines
-- Bart _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Sven Barth
to Virgo Pärna

Virgo Pärna via fpc-pascal schrieb am
Di., 12. Mai 2020, 08:27:

Show quoted text 9 lines
On Tue, 05 May 2020 23:03:33 +0200, Rainer Stratmann < > wrote: > > But that worked a long time (2 years or so) with FPC 2.6.4 > May FPC 2.6.4 was configured to default to delphi or tp mode? In those modes @ is not required to assigne procedure/function to procvar.

FPC's default mode was and is mode FPC.

Regards,
Sven

Reply by email

Virgo Pärna
to Sven Barth
Sven Barth wrote 8 lines
Virgo Pärna via fpc-pascal schrieb am > > May FPC 2.6.4 was configured to default to delphi or tp mode? In > those modes @ is not required to assigne procedure/function to procvar. > FPC's default mode was and is mode FPC.

Yes, but that could have been overridden in configuration file. And if 3.0.4 is installed to different directory, then it could have different configuration file.

Virgo Pärna

Reply by email