Subject: Re: bug#13342: Errors trying to build Guile 2.0.7 [PARTIALLY SOLVED]

From: Peter Teeson <[email-masked]>
Date: Tue, 08 Jan 2013 11:30:36 -0500

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