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

Michael Van Canneyt michael at freepascal.org
Mon Oct 5 15:26:44 CEST 2015

On Mon, 5 Oct 2015, Jonas Maebe wrote:

> 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.

In that case I will add this to the docs.


More information about the fpc-pascal mailing list