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
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#13342: Fwd: bug#13342: Errors trying to build Guile 2.0.7
which was filed against the guile package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 13386 <at> debbugs.gnu.org.
--
13342: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13342
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
tags 13342 notabug
thanks
Hello!
Mark H Weaver <mhw <at> netris.org> skribis:
> FYI, I've posted about this to the libffi-discuss mailing list.
>
> http://sourceware.org/ml/libffi-discuss/2013/msg00012.html
Thanks! So, according to
<http://gcc.gnu.org/ml/gcc/2013-01/msg00449.html>, this is an LLVM bug.
Peter: would you like to report it over at LLVM?
Anyway, closing this bug now. Thanks!
Ludo’.
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Begin forwarded message:
> From: Peter Teeson <pteeson <at> me.com>
> Subject: Re: bug#13342: Errors trying to build Guile 2.0.7
> Date: 7 January, 2013 8:21:59 PM EST
> To: Ludovic Courtès <ludo <at> gnu.org>
>
> 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 39999972255
>>>>> FAIL: test-ffi
>>>>
>>>> This is a known issue when building Guile with LLVM/Clang:
>>>>
>>>> http://bugs.gnu.org/10015
>>>> http://bugs.gnu.org/10681
>>>>
>>>> It would be great if you could investigate.
>
> Here is the result of my investigation - do you agree?
> 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 output
>
> int64 d 40000000000 0X9502F9000
> int32 c -30000 0XFFFF8AD0
> int16 b 2000 0X7D0
> int08 a -1 0XFFFFFFFF
> int64 sum 39999971999 0X9502F229F
>
> (4) This function in /guile-2.0.7/test-suite/standalone/test-ffi
> ;;
> ;; 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 expression
>
> (+ -1 2000 -30000 40000000000)
>
> which 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
[Message part 5 (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.