Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 14:22, Sven Barth via fpc-devel wrote: Only because you can't see a reason for it doesn't mean that it doesn't exist. That is exactly why I asked :) Ondrej ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

Re: [fpc-devel] Question on constref

2023-02-02 Thread Sven Barth via fpc-devel
Ondrej Pokorny via fpc-devel schrieb am Do., 2. Feb. 2023, 12:09: > Delphi cannot do it. FPC rocks! > > The only disadvantage is that you get a FreeAndNil copy for every type > you pass into the parameter (?) > > Do we want to change it in SysUtils? :) > As you might have noticed you need to

Re: [fpc-devel] Question on constref

2023-02-02 Thread Sven Barth via fpc-devel
Ondrej Pokorny via fpc-devel schrieb am Do., 2. Feb. 2023, 10:06: > On 02.02.2023 07:42, Sven Barth via fpc-devel wrote: > > The case when you *need* a constant reference. Case in point: the > > passing of TGuid in IInterface.QueryInterface. Delphi code relies on > > it being a reference, but

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 12:19, Marco van de Voort via fpc-devel wrote: On 2-2-2023 12:00, Ondrej Pokorny via fpc-devel wrote: The only disadvantage is that you get a FreeAndNil copy for every type you pass into the parameter (?) Are they actually made global ? Will two freeandnil in different units use

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 12:25, Mattias Gaertner via fpc-devel wrote: On Thu, 2 Feb 2023 12:00:31 +0100 Ondrej Pokorny via fpc-devel wrote: [...] Delphi cannot do it. FPC rocks! +1 The only disadvantage is that you get a FreeAndNil copy for every type you pass into the parameter (?) Do we want to

Re: [fpc-devel] Question on constref

2023-02-02 Thread Mattias Gaertner via fpc-devel
On Thu, 2 Feb 2023 12:19:46 +0100 Marco van de Voort via fpc-devel wrote: > On 2-2-2023 12:00, Ondrej Pokorny via fpc-devel wrote: > > > > > > The only disadvantage is that you get a FreeAndNil copy for every > > type you pass into the parameter (?) > > Are they actually made global ? yes >

Re: [fpc-devel] Question on constref

2023-02-02 Thread Marco van de Voort via fpc-devel
On 2-2-2023 12:00, Ondrej Pokorny via fpc-devel wrote: The only disadvantage is that you get a FreeAndNil copy for every type you pass into the parameter (?) Are they actually made global ? Will two freeandnil in different units use the same? But that is just curiousity, IMHO this

Re: [fpc-devel] Question on constref

2023-02-02 Thread Mattias Gaertner via fpc-devel
On Thu, 2 Feb 2023 12:00:31 +0100 Ondrej Pokorny via fpc-devel wrote: >[...] > Delphi cannot do it. FPC rocks! +1 > The only disadvantage is that you get a FreeAndNil copy for every > type you pass into the parameter (?) > > Do we want to change it in SysUtils? :) I got a feeling this solves

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 11:00, Michael Van Canneyt via fpc-devel wrote: In userspace, the best seems Function FreeAndNil(Obj : T) : T; begin   Obj.Free;   Result:=Nil; end; With automatic type inference for generics, this allows you to do A:=FreeAndNil(A); Michael, bringing your idea to the next

Re: [fpc-devel] Question on constref

2023-02-02 Thread Sven Barth via fpc-devel
Adriaan van Os via fpc-devel schrieb am Do., 2. Feb. 2023, 09:57: > Sven Barth wrote: > > Adriaan van Os via fpc-devel > > schrieb am Do., 2. Feb. 2023, > > 02:47: > > > > Sven Barth via fpc-devel wrote: > > > > > There is no full documentation

Re: [fpc-devel] Question on constref

2023-02-02 Thread Michael Van Canneyt via fpc-devel
On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 02.02.2023 10:22, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 02.02.2023 10:15, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 10:22, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 02.02.2023 10:15, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: I myself cannot think of any real use case of constref

Re: [fpc-devel] Question on constref

2023-02-02 Thread Michael Van Canneyt via fpc-devel
On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 02.02.2023 10:15, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: I myself cannot think of any real use case of constref other than hacks like the FreeAndNil in recent Delphi

Re: [fpc-devel] Question on constref

2023-02-02 Thread Michael Van Canneyt via fpc-devel
On Thu, 2 Feb 2023, Hairy Pixels via fpc-devel wrote: On Feb 2, 2023, at 3:57 PM, Adriaan van Os via fpc-devel wrote: - under what circumstances (and in what compiler mode) does FPC pass large (say 1 MB or 1 GB) "const" parameters by value (which is extremely inefficient) ? - for what

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 10:15, Michael Van Canneyt via fpc-devel wrote: On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: I myself cannot think of any real use case of constref other than hacks like the FreeAndNil in recent Delphi versions: procedure FreeAndNil(const [ref] Obj: TObject); that

Re: [fpc-devel] Question on constref

2023-02-02 Thread Michael Van Canneyt via fpc-devel
On Thu, 2 Feb 2023, Ondrej Pokorny via fpc-devel wrote: On 02.02.2023 07:42, Sven Barth via fpc-devel wrote: The case when you *need* a constant reference. Case in point: the passing of TGuid in IInterface.QueryInterface. Delphi code relies on it being a reference, but “const” does not

Re: [fpc-devel] Question on constref

2023-02-02 Thread Hairy Pixels via fpc-devel
> On Feb 2, 2023, at 3:57 PM, Adriaan van Os via fpc-devel > wrote: > > - under what circumstances (and in what compiler mode) does FPC pass large > (say 1 MB or 1 GB) "const" parameters by value (which is extremely > inefficient) ? > - for what reasons ? > > As long as these questions are

Re: [fpc-devel] Question on constref

2023-02-02 Thread Ondrej Pokorny via fpc-devel
On 02.02.2023 07:42, Sven Barth via fpc-devel wrote: The case when you *need* a constant reference. Case in point: the passing of TGuid in IInterface.QueryInterface. Delphi code relies on it being a reference, but “const” does not guarantee that for all platforms. Maybe I am missing

Re: [fpc-devel] Question on constref

2023-02-02 Thread Adriaan van Os via fpc-devel
Sven Barth wrote: Adriaan van Os via fpc-devel > schrieb am Do., 2. Feb. 2023, 02:47: Sven Barth via fpc-devel wrote: > There is no full documentation for that parameter modifier (someone > might want to file a bug report for that), but the

Re: [fpc-devel] Question on constref

2023-02-02 Thread Michael Van Canneyt via fpc-devel
On Thu, 2 Feb 2023, Sven Barth via fpc-devel wrote: Am 02.02.2023 um 02:09 schrieb Hairy Pixels: On Feb 2, 2023, at 4:38 AM, Sven Barth wrote: Which types are passed by-value or by-reference when using const is determined by the size of the record and the types of the fields based on

[fpc-devel] Fixing bugs

2023-02-02 Thread J. Gareth Moreton via fpc-devel
Hi everyone, I've just made an update to https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/366, the request that fixes i40111, removing the band-aid in aoptx86 and hopefully still fixing the original bug.  Can everyone confirm that i386-linux no longer crashes? In the meantime

Re: [fpc-devel] Question on constref

2023-02-02 Thread Steve Litt via fpc-devel
Bart via fpc-devel said on Wed, 1 Feb 2023 11:30:37 +0100 >Hi, > >The function is not supposed to alter the contents of this >datastructure. So, I need to pass this structure by reference. >(I've spent hours and hours looking at unexpected results in my >program because I passed the