Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-04

Constant parameters and double types

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luiz Americo Pereira Camara

I'm evaluating the effect of passing function parameters by value or by reference.

Like stated in the documentation, passing as reference (const) or by value types with size equal to pointer size like Integer has no difference in the code output (they are passed by value).

Also as expected i noticed a difference in the generated assembler for types TRect (16bytes) or TPoint (8 bytes).

But for double (8 bytes) the generated assembler are equal for both types of parameters. Is this intentional? For double types, there's no difference in using const modifier?

I'm using a 32bit cpu.

Luiz

Reply by email

Luiz Americo Pereira Camara
to Luiz Americo Pereira Camara
Luiz Americo Pereira Camara wrote 16 lines
I'm evaluating the effect of passing function parameters by value or by reference. Like stated in the documentation, passing as reference (const) or by value types with size equal to pointer size like Integer has no difference in the code output (they are passed by value). Also as expected i noticed a difference in the generated assembler for types TRect (16bytes) or TPoint (8 bytes). But for double (8 bytes) the generated assembler are equal for both types of parameters. Is this intentional? For double types, there's no difference in using const modifier? I'm using a 32bit cpu.

I attached the source code of a small app and the asm output of the functions.

It seems that for double fpc pass by reference if the parameter is not assigned regardless of const modifier. Can someone confirm this?

Reply by email