This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: cast to pointer from integer of different size
- From: Peter Bergner <bergner at vnet dot ibm dot com>
- To: Jack Howarth <howarth at bromo dot msbb dot uc dot edu>
- Cc: gcc at gcc dot gnu dot org, pinskia at physics dot uc dot edu
- Date: Thu, 21 Sep 2006 23:52:17 -0500
- Subject: Re: cast to pointer from integer of different size
- References: <20060922035430.35FB8110010@bromo.msbb.uc.edu>
On Thu, 2006-09-21 at 23:54 -0400, Jack Howarth wrote:
> We have
> the same issue in gcc-4.2-20060915/libffi/src/powerpc/ffi_darwin.c
> (which might explain why it fails so many tests at -m64).
>
> http://gcc.gnu.org/ml/gcc/2006-09/msg00277.html
For this thread, you have:
*next_arg++ = (unsigned)(char *)ecif->rvalue;
Digging through the types, you have:
libffi/include/ffi_common.h:
typedef struct
{
ffi_cif *cif;
void *rvalue;
void **avalue;
} extended_cif;
and from libffi/src/powerpc/ffi_darwin.c:
unsigned *next_arg = stack + 6; /* 6 reserved positions. */
So for -m64, you're taking the 8 byte rvalue void * pointer and
casting it to an 8 byte char * pointer, so that part is ok.
However, you then cast it to a 4 byte unsigned type and store it
to a 4 byte unsigned memory location pointed to by next_arg.
Yes, this code is not 64-bit clean.
Peter