On Wed, 31 Mar 2010, Jonas Maebe wrote:
On 31 Mar 2010, at 20:01, Seth Grover wrote:
The documentation
(http://www.freepascal.org/docs-html/ref/refsu56.html) says "A
constant argument is passed by reference if its size is larger than a
pointer. It is passed by value if the size is equal or is less then
the size of a native pointer."
I have a packed record type defined which contains two 64-bit integers
(so it's obviously bigger than a pointer). I wrote a routine that
takes one of these records as a constant argument (eg., "procedure
Doit(const rec : TMyRecord);")
I compiled it and looked at the assembly being generated, and sure
enough it was being passed by reference, just as the documentation
says. However, if the procedure is declared as "cdecl" the record
itself (its contents) are copied onto the stack.
Should the documentation be updated? Or is this incorrect behavior?
I personally think that the documentation should not say anything at all about how
"const" parameters are passed, as this should be an implementation detail that
nobody should care about.
While I principally agree with you:
It must, for Delphi compatibility. In Delphi the same is true, and
is (unfortunately) documented.
We had this discussion already a couple of times.
Michael.
That said, with "cdecl", "const" has the same meaning as it has in C, which is "pass
the argument exactly the same way as when there is no const modifier".
Jonas_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel