http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56033



Andreas Krebbel <krebbel at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |krebbel at gcc dot gnu.org



--- Comment #5 from Andreas Krebbel <krebbel at gcc dot gnu.org> 2013-04-08 
11:19:16 UTC ---

Confirmed for s390x.



Looks like an endianess issue to me. In cls_struct_va1.c the void pointer to

the return value is cast to an int pointer before writing to it:



static void

test_fn (ffi_cif* cif __UNUSED__, void* resp,

     void** args, void* userdata __UNUSED__)

{

...

  * (int*) resp = 42;

}



But the pointer later on is expected to point to a register size value.



There are also testcases which do it differently (e.g. closure_fn0.c). They

cast the pointer to the return value to ffi_arg* before accessing it. ffi_arg

is defined to be a register size type. From the documentation I cannot tell

which one is supposed to be correct.



static void

closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,

         void* userdata)

{

  *(ffi_arg*)resp = ...

}



Btw. for both examples the return type is defined as &ffi_type_sint in

ffi_prep_cif

Reply via email to