Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-01

Incorrect display of non-zero-indexed arrays in debugger

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lance Boyle

OS X 10.3.7, XCode 1.5, FPC 1.9.6

Still learning FPC in XCode. Here is a little test unit:

unit EmptyPlaceHolderUnit;
interface
    procedure printstuff;
implementation
    procedure printstuff;
       var
          j : longint;
          anotherArray : array[11..14] of real;
       begin
       for j := 11 to 14 do
          anotherArray[j] := 2*j;
       for j := 11 to 14 do
          writeln(anotherArray[j]);
       end;
end.

When debugging this, the debugger incorrectly shows me anotherArray with indices 0..3, not 11..14. The writeln() goes ahead and produces the correct output, but the debugger shows nonsense for the array values, as though it is actually accessing some memory locations that might correspond to anotherArray[0] through anotherArray[3].

In a variation, if I declare anotherArray[1..4] of real, the debugger, as above, shows me anotherArray[0..3], but when the assignment is made to anotherArray[1], the debugger indicates the correct value for anotherArray[1], while anotherArray[0] still shows garbage. Likewise for anotherArray[2..3], but who knows what the debugger thinks happens on assigning to anotherArray[4].

Perhaps the debugger assumes zero-based array indexing and then (with this false assumption), tries to display those values as if the array really does start with zero, in the process accessing incorrect memory locations. Is this a C disease?

Jerry

Reply by email