[fpc-devel] fpc-devel Digest, Vol 178, Issue 38

Martin Frb lazarus at mfriebe.de
Thu Feb 21 15:41:22 CET 2019

On 20/02/2019 19:31, Franz Müller wrote:
> It's a nice example why scoped variables would be in fact better, 
> because the value of i is undefined if the for loop is exited 
> normally. So even the original code wouln't work as expected, you 
> cannot rely on i>High(arr) in that case, it depends on the way the for 
> loop is implemented.
> Using only the variable local to the loop would cause a compiler error, while using only the variable defined in the function body would not even cause a warning but leed to unwanted results.

That does not need inlined variables.

The compiler already has a warning about uninitialized vars. If not 
detected after a for loop, this should be improved (rather than adding 
some other workaround).

And there is a command line switch to tread warnings as errors. So that 
problem is perfectly solve-able.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190221/1d19b1f2/attachment.html>

More information about the fpc-devel mailing list