+++ This bug was initially created as a clone of Bug #32843 +++
> 
> On Linux/ia32, this patch
> 
> http://gcc.gnu.org/ml/gcc-cvs/2007-07/msg00336.html
> 
> caused
> 
> FAIL: libffi.call/return_sc.c -O0 -W -Wall execution test
> FAIL: libffi.call/return_sc.c -O2 execution test
> FAIL: libffi.call/return_sc.c -O3 execution test

The fix for this bug broke win32.  The final patch in bug 32843 comment 17:

  http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131343

added support for Darwin by introducing two extended return value types:

> +#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
> +#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)

and code in x86/ffi.c#ffi_prep_cif_machdep to use those types in preference to
equivalent int sizes:

> @@ -142,11 +146,11 @@
>      case FFI_TYPE_STRUCT:
>        if (cif->rtype->size == 1)
>          {
> -          cif->flags = FFI_TYPE_SINT8; /* same as char size */
> +          cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
>          }
>        else if (cif->rtype->size == 2)
>          {
> -          cif->flags = FFI_TYPE_SINT16; /* same as short size */
> +          cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
>          }
>        else if (cif->rtype->size == 4)
>          {

... but it didn't add any code in any of the functions in x86/win32.S to handle
the new extended return codes; right now they fall through and get mistaken for
no return value at all.

  I'm working on a patch.  Hmm, looking closer, it seems that win32.S doesn't
handle any of the UINT types either.  Groan.  I guess I'll adapt the jump table
approach as seen in sysv.S/darwin.S and fill out every case.

  I notice that ffi_call_SYSV has to handle all the return types, but not
ffi_closure_SYSV nor ffi_closure_raw_SYSV.  Does anyone know why that is?


-- 
           Summary: [4.5 Regression] : libffi.call/return_sc.c
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libffi
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dave dot korn dot cygwin at gmail dot com
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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

Reply via email to