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.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to