[fpc-devel] Evaluation order in expressions

Michael Van Canneyt michael at freepascal.org
Tue Jul 30 08:33:45 CEST 2019



On Tue, 30 Jul 2019, Ondrej Pokorny wrote:

> On 30.07.2019 08:23, Ondrej Pokorny wrote:
>> /Remark: The order in which expressions of the same precedence are 
>> evaluated is not guaranteed to be left-to-right./
>> 
>> Is this valid for boolean expressions, too? I use the following construct 
>> with {$BOOLEVAL OFF}:
>> Result := Assigned(MyObject) and (MyObject.Value>5);
>> 
> A moment of relief. The FPC compiler itself depends on the left-to-right 
> evaluation. E.g. compiler/aoptbase.pas, line 284:
>
>     while assigned(p1) and assigned(p2) and GetNextInstruction(p1,p1) and 
> (p1<>p2) do
>
>
> So is the documentation wrong or are the compiler (and also my own) sources 
> flawed?

The documentation has already been fixed in this regard, there was a
bugreport about it not so long ago.

Michael.


More information about the fpc-devel mailing list