I know that many fortran compilers would just optimize the whole loop away. Are you certain that the compiled C program wasn't also similiarily affected?
-- Travis Griggs
No, I supposed such optimizations, but I was wrong.
If you look closely, it does, partially.
Essentially, the above is:
mov ecx,Array[0] label: dec eax mov ecx,3 jne label mov Array[0],ecx
The compiler did put the array element into a register. This saves a memory write for each step.
--Bert
Well, you are right, but it is other kind of optimization, isn't it? This is "use register for some variables (register allocation)" but we expected "do not do what has no effect".
Viktor