Toby Ewing wrote:
Finally got it.
In the end the problem wasn't in the list work at all. Way earlier in the program, I'd allocated memory for an array [1..x], then accessed it as [0..x]. On freeing the memory, I guess something funny was set up in the memory manager that came back to bite me way later.
So... is there a compiler option I could have set that would have told me about this illegal memory access?
Glad to hear it. Now I won't do any stewing :-) gpc's lack of runtime range checking bites again :-[ But I'll bet a lot of it was your fault, in failing to declare a suitable index type and then the array as
aindex = 1..maxarr; ... arr : array[aindex] of whatever;
I'm not sure if gpc would then detect assignment of an out of range constant.
I maintain that careful declaration of vars and types, using the closest possible limits, pays off in the end.