GNU bug report logs - #13342
Clang, the FFI, and 8-bit signed integers

Previous Next

Package: guile;

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 #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peter Teeson <peter.teeson <at> me.com>
To: bug-guile <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: Re: bug#13342: Errors trying to build Guile 2.0.7 [PARTIALLY SOLVED]
Date: Tue, 08 Jan 2013 11:30:36 -0500
[Message part 1 (text/plain, inline)]
Hi Ludo:

I believe my conjecture that -1 was correct based on the following:

(0) I took the printf statements from my test program and placed them in 
test-ffi-sum:

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-assinging of a!
    printf("scm_t_int16 a %" "hd" " %#X \n", a,a);

    return d + c + b + a;
}

(1) Ran make 

Making all in standalone
make  all-am
  CC       libtest_ffi_la-test-ffi-lib.lo
  CCLD     libtest-ffi.la

and then make check

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) Since scm_t_int8 is only 8 bits wide it's maximum value is 0xFF <=> 255
Reassigning "a" to be -1 allowed it to pass the test.

(3) Therefore I conclude that this is why the test fails (correctly IMHO).
You can only get a litre of milk into a litre jar!

(4) Where do we go from here?

respect

Peter
[Message part 2 (text/html, inline)]

This bug report was last modified 12 years and 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.