[fpc-devel] Question on constref

Adriaan van Os adriaan at adriaan.biz
Thu Feb 2 09:57:32 CET 2023


Sven Barth wrote:
> Adriaan van Os via fpc-devel <fpc-devel at lists.freepascal.org 
> <mailto:fpc-devel at lists.freepascal.org>> 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 documentation for
>      > “const” (
>      >
>     https://www.freepascal.org/docs-html/current/ref/refsu67.html#x183-20700014.4.4
> 
>      > ) contains this:
>      >
>      > === doc begin ===
>      >
>      > Contrary to Delphi, no assumptions should be made about how const
>      > parameters are passed to the underlying routine. In particular, the
>      > assumption that parameters with large size are passed by
>     reference is
>      > not correct. For this the constref parameter type should be used,
>     which
>      > is available as of version 2.5.1 of the compiler.
>      >
>      > === doc end ===
> 
>     On debate, see FPC issue 17442.
> 
> 
> There is no debate planned for this in the near future. So even if this 
> might change some time in the future it does not *now* and very likely 
> also not for 3.4.0. Not to mention that things wouldn't change for most 
> platforms anyway, because they only have the platform ABI available and 
> that *must not* change for compatibility with C code. 

"Will not change" and "ABI" are non arguments. They do not address the questions put forward here:

- 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 not addressed and cleared and documented "const" parameters are not 
a useable in actual code.

Regards,

Adriaan van Os



More information about the fpc-devel mailing list