[fpc-pascal]Strange indexing problem - gdb or fpc?

JOHN COPPENS jcoppens at usa.net
Mon Apr 22 06:38:03 CEST 2002


Hi...

I'm debugging (trying to) a program, was nearing the problem, and
found this strange behaviour:

820             rconst[r+1] := x;
(gdb) print RCONST[0]                  //  Still 0
$5 = 0
(gdb) print R
$6 = 0                                 //   Was initialized like this
(gdb) print X
$7 = 0.29999999999999999               //  New value
(gdb) next			       //  Execute the rconst[r+1] := x
821             realindex := 1;
(gdb) print RCONST[0]
$8 = 0.29999999999999999               //  Should've been in [1]!!!
(gdb) print R
$9 = 0                                 //  R is 0, so r+1 = 1
(gdb) print X
$10 = 0.29999999999999999

  realarray = array[1..rmax] of real;
  rconst: realarray;

BTW, RCONST[1] is 0 after the operation. Any ideas?

Is this because C arrays are 0 based? I checked the Docs, they don't
mention this problem...

John





More information about the fpc-pascal mailing list