This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
cast to pointer from integer of different size
- From: howarth at bromo dot msbb dot uc dot edu (Jack Howarth)
- To: pinskia at physics dot uc dot edu
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 21 Sep 2006 23:06:10 -0400 (EDT)
- Subject: cast to pointer from integer of different size
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...
typedef struct StackFrame {
unsigned long savedSP;
unsigned long savedCR;
unsigned long savedLR;
unsigned long reserved[2];
unsigned long savedRTOC;
} StackFrame;
unsigned long FindTopOfStack(unsigned int stack_start) {
StackFrame *frame;
if (stack_start == 0) {
# ifdef POWERPC
# if CPP_WORDSZ == 32
__asm__ volatile("lwz %0,0(r1)" : "=r" (frame));
# else
__asm__ volatile("ld %0,0(r1)" : "=r" (frame));
# endif
# endif
} else {
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;
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?
Jack