From: Peter Teeson <pteeson@me.com>Subject: Re: bug#13342: Errors trying to build Guile 2.0.7Date: 7 January, 2013 8:21:59 PM ESTTo: Ludovic Courtès <ludo@gnu.org>Here is the result of my investigation - do you agree?Hi Ludo:On 2013-01-04, at 12:23 PM, Ludovic Courtès wrote:bad return from expression `(f-sum -1 2000 -30000 40000000000)': expected 39999971999; got 39999972255FAIL: test-ffiThis is a known issue when building Guile with LLVM/Clang:http://bugs.gnu.org/10015http://bugs.gnu.org/10681It would be great if you could investigate.My hypothesis is that the scheme interpreter is not calculating the sum correctly based on the following:(0) First observe this"In Apple's version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++."(1) Also we note that 39999972255 - 39999971999 = 256!(2) This program//// main.c// testffi//// Created by Peter Teeson on 13-01-07.// Copyright (c) 2013 PHT Software. All rights reserved.//#include <stdio.h>#include <inttypes.h>int64_t test_ffi_sum (int8_t a, int16_t b,int32_t c, int64_t d);int64_t test_ffi_sum (int8_t a, int16_t b,int32_t c, int64_t d){printf("int64 d %" PRId64 " %#llX \n", d,d);printf("int32 c %" PRId32 " %#X \n", c,c);printf("int16 b %" PRId16 " %#X \n", b,b);printf("int08 a %" PRId8 " %#X \n", a,a);int64_t sum = d + c + b + a;printf("int64 sum %" PRId64 " %#llX \n", sum,sum);return sum;}int main(int argc, const char * argv[]){test_ffi_sum(-1, 2000, -30000, 40000000000);return 0;}(3) produces this outputint64 d 40000000000 0X9502F9000int32 c -30000 0XFFFF8AD0int16 b 2000 0X7D0int08 a -1 0XFFFFFFFFint64 sum 39999971999 0X9502F229F(4) This function in /guile-2.0.7/test-suite/standalone/test-ffi(+ -1 2000 -30000 40000000000);;;; Multiple int args of differing types;;(define f-sum(pointer->procedure int64 (dynamic-func "test_ffi_sum" lib)(list int8 int16 int32 int64)))(test (f-sum -1 2000 -30000 40000000000)(+ -1 2000 -30000 40000000000))might be the culprit and I am guessing that it is this expressionwhich the scheme interpreter is calculating incorrectly. Probably related to -1;Since I am not familiar with the scheme/guile language I can't go any further than this without help.Let me know if I can do more.respect…..Peter