It seems to work with both Delphi and FPC, but I don't know if that because this code is simple or not. (it is possible that the compilers decide to force the loopvar to a variable, essentially changing the for to a while, and then it would be safe).
However, working around errors like this is not smart. If it is forbidden, there is a good reason. Use break or rewrite the for loop using a different looping concept (while/repeat)