[fpc-pascal] for loop variable value reliable after loop?

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Oct 5 15:09:07 CEST 2015


Michael Van Canneyt wrote on Mon, 05 Oct 2015:

> On Mon, 5 Oct 2015, Sven Barth wrote:
>
>> The for-loop-variable contains a valid value after the loop if the loop was
>> left using a break or goto (this does not seem to be documented in FPC's
>> language reference guide, but AFAIK it is in Delphi; also don't know what
>> the ISO standard says about this...).
>
> I am not sure that this is intentional. In fact I seem to remember  
> mails from Jonas to the contrary, but he would need to confirm/deny  
> that. As far as I know, the for loop variable is supposed to be  
> undefined after the loop.

Yes, except if you use break/goto. Sven is correct and it's indeed the  
same in TP and Delphi.


Jonas



More information about the fpc-pascal mailing list