I’ve been having a strange problem that I’ve never seen before. Now I have a for loop:
var
a,counter: byte;
begin
a:=0;
for counter := 1 to 10 do//I put a breakpoint at this line
begin
a:=a*5;
a:=a+counter;
end;
end;
If I put a breakpoint at the line above and try to step into the loop I can’t do it. The debugger immediately steps over the loop and goes to the end.In the end I get the right result, but I can’t follow the loop step by step. I mean this is just a simple example and not the real task. I just want to know when in what circumstances does this happen? I definitely remember tracking through all the steps of a loop. I work with Delphi 2010.
Both lines of code in the loop can be completely optimized away; you do nothing with
aoutside the loop, so both of the assignments are unnecessary. After the optimization, the compiler is leavingActually, if you didn’t have a breakpoint there, the loop would be removed as well, as it does nothing.
If you’re having problems with your code, and the info above doesn’t help (using the variable
aafter the loop runs), you need to post your real code. This made-up code is very clear to analyze; the problem in your actual code may be this simple, or much more complex to analyze.