Variable inspection uses wrong index for reading characters from string, showing S[I+1] instead of S[I]
Original Reporter info from Mantis: dezlov
-
Reporter name: Denis Kozlov
Original Reporter info from Mantis: dezlov
- Reporter name: Denis Kozlov
Description:
Debugger features use a wrong index when inspecting the character value of a string, e.g. S[I]. In fact, you are going to see S[I+1] instead of S[I].
A simple demonstration is attached. This affect all of the debugger features, e.g. watch, inspect, mouse over in IDE.
Check the "Steps To Reproduce" for more info.
Steps to reproduce:
- Use the code below as a sample program.
- Set breakpoint on a first WriteLn.
- Run the program and wait for the breakpoint to be triggered.
- Once breakpoint is triggered, inspect values of I and S[I].
Upon the first breakpoint inspection, you will get:
S='12345'; I=1; S[I]='2'; S[I+1]='3';
In reality, it should be:
S='12345'; I=1; S[I]='1'; S[I+1]='2';
==========================================
program Project1;
{$mode objfpc}{$H+}
uses
Classes;
const
S: string = '12345';
A: array [1..5] of Char = ('1', '2', '3', '4', '5');
var
I: Integer;
begin
for I := 1 to Length(S) do
WriteLn(I, '=', S[I], S[I+1]);
for I := Low(A) to High(A) do
WriteLn(I, '=', A[I], A[I+1]);
end.
==========================================
P.S. I've included an array of chars in the example to double check and demonstrate that inspection of array values does not get affected by this issue.
Additional information:
Lazarus 0.9.30.2
FPC 2.4.4
Mantis conversion info:
- Mantis ID: 20710
- OS: XP
- OS Build: SP3
- Platform: Windows
- Monitored by: » dezlov (Denis Kozlov)