This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cast to pointer from integer of different size


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]