Bug report: small integral values returned as int

Philip W. L. Fong pwlfong@yahoo.com
Fri Mar 15 14:39:00 GMT 2002


Hi

I am using libffi for my implementation of a JVM. I suspect
there is a bug in the sparc port of libffi.  When an integral
value smaller than int, for example, an uint8, is returned
from a foreign function, an int is returned instead.  This
happens to a number of integral types including sint8, sint16, 
and uint16.  This phenomenon does not occur in on x86.  I also
tried using a more recent CVS snapshot (2002/03/13), and the
same thing occurs.

The bug can be reproduced by the attched C program.  The program
basically uses ffi_call to invoke a constant function that always 
return an uint8 value 1.  Then the returned value is collected into
an int-sized buffer.  When the content of the buffer is treated
as an uint8, 0 is printed instead of the expected output 1.
When the content of the buffer is treated as an int, 1 is printed.
This seems to indicate that the returned value is actually an
int rather than a uint8.

Am I missing something, or is this a genuine bug?  Is there a 
quick fix for this in case this is a bug?

Thank you in advance.

Philip

=====
* Philip W. L. Fong
* pwlfong@yahoo.com
* http://www.cs.sfu.ca/~pwfong

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.c
Type: application/octet-stream
Size: 348 bytes
Desc: bug.c
URL: <http://sourceware.org/pipermail/libffi-discuss/attachments/20020315/d34e957e/attachment.obj>


More information about the Libffi-discuss mailing list