Re: Moral on the -1 passed as array index?
An array index of -1 can certainly be used, in languages like Pascal, or even Fortan, or, with care and documentation in languages like C(++). For some arrays it is natural to have an index range of e.g. -N to N. In Pascal-like language you just declare the array that way. It is not that difficult to get it right in C(++).
It seems to me that the key problem is the silent coercion of a signed int to an unsigned int. Strong typing would have trapped this error, I feel. If I already have element numbers 0, 1, and 2, and add element number -1 to a dynamically allocated array, I can do that by allocating a 4 element array, incrementing the pointer, and copying the data to the right elements. Of course, when freeing the array, you must first decrement the pointer accordingly. Writing a class to do this safely is not that hard, although there is every chance people get it wrong.