[fpc-devel] Debugging Loop Unroll Optimization
lazarus at kluug.net
Mon May 21 20:58:41 CEST 2018
On 21.05.2018 20:43, Florian Klämpfl wrote:
> What do you expect?
That it writes a sequence from 1 to 10 to console. Instead, it writes 10
> That it just works?
Please define what you understand with "it just works". (If you agree
with me on the sequence from 1 to 10, my answer is yes.)
> If yes, what about
> program LoopUnrollTest;
> procedure Test;
> I: Integer;
> procedure Test2;
> for I := 1 to 10 do
In this (your) case I don't expect anything - it is one of FPC's
favorites "undefined behaviour" because as documented, it is not allowed
to change the loop variable value within a for loop.
In my case (without the I:=1 assignment) I don't change the loop
variable value - it is absolutely valid to read from it.
More information about the fpc-devel