diff mbox

[libffi,testsuite] Cast void * to uintptr_t first in cls_pointer*.c (PR libffi/46661)

Message ID yddhbce4v4g.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Feb. 8, 2011, 11:35 a.m. UTC
Two libffi testcases currently fail on IRIX 6.5 for the N32 ABI:

FAIL: libffi.call/cls_pointer.c -O0 -W -Wall (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/irix/libffi/testsuite/libffi.call/cls_pointer.c: In function 'main':
/vol/gcc/src/hg/trunk/irix/libffi/testsuite/libffi.call/cls_pointer.c:68:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

The line in question is

	res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);

and ffi_arg is defined as

/* N32 and N64 frames have 64bit integer args */
typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));

in src/mips/ffitarget.h.

Although I have no idea why gcc would warn about casting a pointer to a
*wider* integer type, the warning can be avoided by casting to uintptr_t
first.

The following patch does this, tested with the appropriate runtest
invocations for both ABIs on mips-sgi-irix6.5, i386-pc-solaris2.11 and
sparc-sun-solaris2.11.

Ok for mainline and the 4.5 branch after testing there?

	Rainer


2011-02-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libffi/46661
	* testsuite/libffi.call/cls_pointer.c (main): Cast void * to
	uintptr_t first.
	* testsuite/libffi.call/cls_pointer_stack.c (main): Likewise.

Comments

Andreas Tobler Feb. 8, 2011, 7:20 p.m. UTC | #1
On 08.02.11 12:35, Rainer Orth wrote:
> Two libffi testcases currently fail on IRIX 6.5 for the N32 ABI:
>
> FAIL: libffi.call/cls_pointer.c -O0 -W -Wall (test for excess errors)
> Excess errors:
> /vol/gcc/src/hg/trunk/irix/libffi/testsuite/libffi.call/cls_pointer.c: In function 'main':
> /vol/gcc/src/hg/trunk/irix/libffi/testsuite/libffi.call/cls_pointer.c:68:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> The line in question is
>
> 	res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
>
> and ffi_arg is defined as
>
> /* N32 and N64 frames have 64bit integer args */
> typedef unsigned int     ffi_arg __attribute__((__mode__(__DI__)));
> typedef signed   int     ffi_sarg __attribute__((__mode__(__DI__)));
>
> in src/mips/ffitarget.h.
>
> Although I have no idea why gcc would warn about casting a pointer to a
> *wider* integer type, the warning can be avoided by casting to uintptr_t
> first.
>
> The following patch does this, tested with the appropriate runtest
> invocations for both ABIs on mips-sgi-irix6.5, i386-pc-solaris2.11 and
> sparc-sun-solaris2.11.
>
> Ok for mainline and the 4.5 branch after testing there?

Ok from AG and me.

Danke & Gruss,
Andreas
diff mbox

Patch

diff -r 8fab3983de1b libffi/testsuite/libffi.call/cls_pointer.c
--- a/libffi/testsuite/libffi.call/cls_pointer.c	Fri Feb 04 19:23:36 2011 +0100
+++ b/libffi/testsuite/libffi.call/cls_pointer.c	Tue Feb 08 12:24:00 2011 +0100
@@ -65,7 +65,7 @@ 
 
 	CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
 
-	res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
+	res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2);
 	/* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
 	printf("res: 0x%08x\n", (unsigned int) res);
 	/* { dg-output "\nres: 0x9be02467" } */
diff -r 8fab3983de1b libffi/testsuite/libffi.call/cls_pointer_stack.c
--- a/libffi/testsuite/libffi.call/cls_pointer_stack.c	Fri Feb 04 19:23:36 2011 +0100
+++ b/libffi/testsuite/libffi.call/cls_pointer_stack.c	Tue Feb 08 12:24:00 2011 +0100
@@ -129,7 +129,7 @@ 
 
 	CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
 
-	res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
+	res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2);
 
 	printf("res: 0x%08x\n", (unsigned int) res);
 	// { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" }