[fpc-devel] Debugging Loop Unroll Optimization
J. Gareth Moreton
gareth at moreton-family.com
Fri May 18 14:07:54 CEST 2018
Lawyers or not, well-defined behaviour can only be a good thing for a
language. As for those code snippets in the VCL and the like, unless we
want to change the rule so that the for-loop counter has a distinct value
afterwards, Result should be explicitly set after the for loop (presumably
people want "High + 1").
What's the easiest solution to this? Change the code or change the rule?
Gareth aka. Kit
On Fri 18/05/18 12:46 , Mattias Gaertner nc-gaertnma at netcologne.de sent:
On Fri, 18 May 2018 13:28:30 +0200 (CEST)
marcov at stack.nl  (Marco van de Voort) wrote:
> > > "After the for statement terminates (provided this was not forced by
a Break or an Exit procedure), the value of counter is undefined."
> Well, well, clearly. One could interpret it that it says that the for
> statement terminates naturally if not forced by break or exit. It
> say what happens with break or exit.
If the value of counter is undefined no matter what, then you would
not bother writing the exception in the brackets, wouldn't you?
> The fact that this exception is not documented with an example makes it
> ambiguous IMHO.
I found a dozen places in the VCL using this.
For Result:=...do if ... then exit;
fpc-devel maillist - fpc-devel at lists.freepascal.org 
 mailto:marcov at stack.nl
 mailto:fpc-devel at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel