GNU bug report logs -
#13342
Clang, the FFI, and 8-bit signed integers
Previous Next
Reported by: Peter Teeson <pteeson <at> me.com>
Date: Wed, 2 Jan 2013 23:06:02 UTC
Severity: normal
Tags: notabug
Merged with 13386
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
Full log
Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Ludo:
I think the reason that we get this error is that the "a" argument is declared to be only 8 bits wide
but is passed in as -1 which is correctly represented as 0xFFFFFFFF
However an 8-bit representation is 0xFF which is only 255.
Here is how I tracked it down:
(0) Took the printf's from my test program and placed them in
scm_t_int64 test_ffi_sum (scm_t_int8 a, scm_t_int16 b,
scm_t_int32 c, scm_t_int64 d);
scm_t_int64 test_ffi_sum (scm_t_int8 a, scm_t_int16 b,
scm_t_int32 c, scm_t_int64 d)
{
scm_t_int64 sum;
printf("scm_t_int64 d %" "ll" "d" " %#llX \n", d,d);
printf("scm_t_int32 c %" "d" " %#X \n", c,c);
printf("scm_t_int16 b %" "hd" " %#X \n", b,b);
printf("scm_t_int8 a %" "hh" "d" " %#X \n", a,a);
sum = d + c + b + a;
printf("scm_t_int64 sum %" "ll" "d" " %#llX \n", sum,sum);
a = -1; // NOTE:re-assign of a!!!!
printf("scm_t_int16 a %" "hd" " %#X \n", a,a);
return d + c + b + a;
}
(1) Did make and make check with the following result
scm_t_int64 d 40000000000 0X9502F9000
scm_t_int32 c -30000 0XFFFF8AD0
scm_t_int16 b 2000 0X7D0
scm_t_int8 a -1 0XFF
scm_t_int64 sum 39999972255 0X9502F239F
scm_t_int16 a -1 0XFFFFFFFF
PASS: test-ffi
(2) Observe that the test passed.
So I think my original suspicion seems to have been confirmed.
I do not know where to go from here but await your further instructions.
respect
Peter
[Message part 2 (text/html, inline)]
This bug report was last modified 12 years and 111 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.