[fpc-pascal] Illeagal assignment to For Loop variable in Free pascal

Sven Barth pascaldragon at googlemail.com
Wed Jun 18 06:41:49 CEST 2014


Am 18.06.2014 04:55 schrieb "Jim Leonard" <trixter at oldskool.org>:
>
> The error is because FreePascal optimizes loops wherever it can, and
trying to modify the loop variable would break under that optimization.
>
> While you could enable compilation flags to make things more TP
compatible, looking at the code, I can see that the 'counter:=1' is just an
early termination clause.  If the variable 'counter' isn't needed after
that section, you could replace that line with 'break' which would exit the
loop immediately (which is what the code does now).

One shouldn't assume anything about the loop variable after the execution
of the loop anyway *except* the loop was left using Break or Goto.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140618/c722c305/attachment.html>


More information about the fpc-pascal mailing list