[fpc-devel] cdecl and constant parameters
sethdgrover at gmail.com
Wed Mar 31 20:01:01 CEST 2010
(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?
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.
More information about the fpc-devel