This is the mail archive of the libffi-discuss@sources.redhat.com mailing list for the libffi 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]

Bug report: small integral values returned as int


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/

Attachment: bug.c
Description: bug.c


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