[fpc-devel] Debugging Loop Unroll Optimization

Marco van de Voort marcov at stack.nl
Fri May 18 13:28:30 CEST 2018


In our previous episode, Mattias Gaertner said:
> > ISO7185: "After a for-statement is executed, other than being left by a goto-statement, the
> > control-variable shall be undefined"
> > 
> > http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Declarations_and_Statements_(Delphi)#For_Statements:
> > "After the for statement terminates (provided this was not forced by a Break or an Exit procedure),
> > the value of counter is undefined."
> > 
> > So this shall not be unrolled, but is still error prone, if Result is not set after the regular end of the for loop.
> 
> To avoid misunderstandings:
> The above clearly says, that using break/goto/exit is safe:


Well, well, clearly. One could interpret it that it says that the for
statement terminates naturally if not forced by break or exit.  It doesn't
say what happens with break or exit.
 
The fact that this exception is not documented with an example makes it very
ambiguous IMHO.



More information about the fpc-devel mailing list