Different behaviour between FPC 2.6.4 and FPC 3.0.4

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Different behaviour between FPC 2.6.4 and FPC 3.0.4

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




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Alexander Grotewohl
procvar:=@proc_bool; ?

--
Alexander Grotewohl
https://dcclost.com


From: fpc-pascal <[hidden email]> on behalf of Rainer Stratmann <[hidden email]>
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  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Rainer Stratmann
Am Dienstag, 5. Mai 2020, 22:14:09 CEST schrieb Alexander Grotewohl:
> procvar:=@proc_bool; ?

Error: Incompatible types

> --
> Alexander Grotewohl
> https://dcclost.com
>
> ________________________________
> From: fpc-pascal <[hidden email]> on behalf of
> Rainer Stratmann <[hidden email]> 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  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Jonas Maebe-3
In reply to this post by Rainer Stratmann
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Alexander Grotewohl
In reply to this post by Rainer Stratmann
my original suggestion and then

function proc_bool : boolean;

what exactly are you trying to accomplish?

--
Alexander Grotewohl
https://dcclost.com

From: fpc-pascal <[hidden email]> on behalf of Rainer Stratmann <[hidden email]>
Sent: Tuesday, May 5, 2020 4:20:11 PM
To: FPC-Pascal users discussions <[hidden email]>
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:
> procvar:=@proc_bool; ?

Error: Incompatible types

> --
> Alexander Grotewohl
> https://dcclost.com
>
> ________________________________
> From: fpc-pascal <[hidden email]> on behalf of
> Rainer Stratmann <[hidden email]> 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  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Rainer Stratmann
YES that works, thank you!


Am Dienstag, 5. Mai 2020, 22:27:12 CEST schrieb Alexander Grotewohl:

> my original suggestion and then
>
> function proc_bool : boolean;
>
> what exactly are you trying to accomplish?
>
> --
> Alexander Grotewohl
> https://dcclost.com
> ________________________________
> From: fpc-pascal <[hidden email]> on behalf of
> Rainer Stratmann <[hidden email]> Sent: Tuesday, May 5, 2020
> 4:20:11 PM
> To: FPC-Pascal users discussions <[hidden email]>
> 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:
> > procvar:=@proc_bool; ?
>
> Error: Incompatible types
>
> > --
> > Alexander Grotewohl
> > https://dcclost.com
> >
> > ________________________________
> > From: fpc-pascal <[hidden email]> on behalf of
> > Rainer Stratmann <[hidden email]> 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  -  [hidden email]
> > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Free Pascal - General mailing list
In reply to this post by Rainer Stratmann
On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann
<[hidden email]> wrote:

> Did I overlooked something?

Your function returns a functiontype?
Is that intended?

--
Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Rainer Stratmann
Am Dienstag, 5. Mai 2020, 22:53:53 CEST schrieb Bart via fpc-pascal:
> On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann
>
> <[hidden email]> 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!
 
> --
> Bart
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Rainer Stratmann
In reply to this post by Free Pascal - General mailing list
Am Dienstag, 5. Mai 2020, 22:53:53 CEST schrieb Bart via fpc-pascal:
> On Tue, May 5, 2020 at 10:05 PM Rainer Stratmann
>
> <[hidden email]> 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 :-)
 
> --
> Bart
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Free Pascal - General mailing list
In reply to this post by Rainer Stratmann
On Tue, 05 May 2020 23:03:33 +0200, Rainer Stratmann <[hidden email]> 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.

--
Virgo Pärna
[hidden email]

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Free Pascal - General mailing list
Virgo Pärna via fpc-pascal <[hidden email]> schrieb am Di., 12. Mai 2020, 08:27:
On Tue, 05 May 2020 23:03:33 +0200, Rainer Stratmann <[hidden email]> 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 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Different behaviour between FPC 2.6.4 and FPC 3.0.4

Free Pascal - General mailing list
On Tue, 12 May 2020 11:05:15 +0200, Sven Barth via fpc-pascal <[hidden email]> wrote:
> Virgo Pärna via fpc-pascal <[hidden email]> 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
[hidden email]

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal