[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 [1] (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
doesn't 
 > 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
very 
 > ambiguous IMHO. 

 I found a dozen places in the VCL using this. 
 For Result:=...do if ... then exit; 

 Mattias 
 _______________________________________________ 
 fpc-devel maillist - fpc-devel at lists.freepascal.org [2] 
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel [3]"
target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


 

Links:
------
[1] mailto:marcov at stack.nl
[2] mailto:fpc-devel at lists.freepascal.org
[3] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180518/78e39e0d/attachment.html>


More information about the fpc-devel mailing list