[fpc-devel] Evaluation order in expressions
Michael Van Canneyt
michael at freepascal.org
Tue Jul 30 09:46:47 CEST 2019
On Tue, 30 Jul 2019, Ondrej Pokorny wrote:
> On 30.07.2019 08:55, Jonas Maebe wrote:
>> Delphi evaluates e.g. all parameters to subroutine calls from left to
>> right, which FPC does not guarantee.
>
> If I am not mistaken Delphi doesn't guarantee this either. I remember I
> "learned it by doing" quite some time ago and I don't think I used FPC
> at that point, so it must have been Delphi.
>
> A quick Google search revealed https://stackoverflow.com/a/11010685 -
> yes, when I run the code from the answer in Delphi 32bit the right
> "SideEffect(2)" call is executed before the left "SideEffect(1)" call.
I think they updated the documentation meanwhile:
http://docwiki.embarcadero.com/RADStudio/Rio/en/Procedures_and_Functions_(Delphi)#Calling_Conventions
So you can see it depends on the calling convention.
Michael.
More information about the fpc-devel
mailing list