On Thu, 2006-09-21 at 23:06 -0400, Jack Howarth wrote: > Andrew, > I've been trying to get a handle on why the line... > > frame = (StackFrame *)stack_start; > > in gcc/boehm-gc/darwin_stop_world.c only generates the warning... > > ../../../../gcc-4.2-20060920/boehm-gc/darwin_stop_world.c:76: warning: cast > to pointer from integer of different size > > when compiled at -m64 on Darwin PPC but not -m32. This code section is...
Assuming Darwin PPC is similar to Linux PPC in using a LP64 model for 64-bit apps, you're trying to take a 4 byte integer (sizeof(int) == 4) and assigning it to an 8 byte pointer (sizeof(void *) == 8). You don't get a warning when using frame->savedSP, because sizeof(unsigned long) is 8 bytes which is the same as a pointer. There's no problem when compiling with -m32, because int, long and void * are all 4 bytes in size. > The first is assigning an unsigned int to frame whereas the > second assigns an unsigned long. However I don't quite see > how to figure out what type Stackframe is equivalent to > and why it is different at -m64. More importantly is this > sort of warning indicative of a latent bug at -m64 or is > it harmless? This is indicative of code that is not 64-bit clean. Imagine taking that 8 byte pointer and throwing away half the bits by storing it into 4 byte variable. It doesn't work too well as a pointer after that. We ran into this type of problem in spades when we created the 64-bit Linux PPC kernel using the 32-bit Linux PPC kernel as a starting point. Peter