On 22 September 2006 04:06, Jack Howarth wrote:

>     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.

> unsigned long FindTopOfStack(unsigned int stack_start) {

>     frame = (StackFrame *)stack_start;

> The line a little further in the code assigns to frame as well
> with a cast to (StackFrame*) but never generates the warning.
> 
>     frame = (StackFrame*)frame->savedSP;

> typedef struct StackFrame {
>   unsigned long savedSP;

> 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

  It's a /pointer/ to StackFrame.  That's the important bit.

> and why it is different at -m64. 

  Because at -m32, you have ILP32, and at -m64, you get LP64, and it's only
when pointers are bigger than ints that you'll get the warning, and longs are
the same size as pointers in both cases.

  See http://www.unix.org/version2/whatsnew/lp64_wp.html for a quick summary,
and also think about what

> #   if CPP_WORDSZ == 32
>       __asm__ volatile("lwz     %0,0(r1)" : "=r" (frame));
> #   else
>       __asm__ volatile("ld      %0,0(r1)" : "=r" (frame));
> #   endif

is doing.

> is this
> sort of warning indicative of a latent bug at -m64 or is
> it harmless?

  That I'll leave to someone who knows the darwin abi.  If it guarantees that
the stack is always located in the low 4Gb of process address space, it might
be ok.  I dunno.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

Reply via email to