John Maloney wrote:
As I read it the memory has been malloced high up and all those ints that represent addresses have become negative, breaking the pointer arithmetic.
So...shouldn´t all variables that hold addresses (OOPs) be declared as unsigned instead of int (or am I barking up the wrong tree) ?
Yes, or (void *) perhaps. But I'd hate to have to put all those type declarations into the Smalltalk code that is used to generate the C code for the VM...
This highlights a strange issue I found when looking at the interpreter simulator: the simulator code treats everything in memory as unsigned whereas the generated C-code treats it, with a few explicit exceptions, as signed. Perhaps the best solution is to make the default declaration in the C-code unsigned and fix the places where signed is essential. Could still be a lot of work though...
Using void* carries a risk. Nothing in the C standard prevents a compiler from generating signed comparisons between pointers. And yes, I have learned this the hard way; it's not entirely hypothetical.
Wim Boot