0.7 / 1.0 ?= 0.52

Torbjorn Granlund tg at gmplib.org
Fri Jun 15 15:07:13 CEST 2012


Hans Aberg <haberg-1 at telia.com> writes:

  > The division produce a funny bug. What do you think?
  > 
  >    mpf_t a;
  >    mpf_init(a);
  >    mpf_set_d(a, 0.7);
  >    mpf_t b;
  >    mpf_init(b);
  >    mpf_set_d(b, 1.0);
  >    mpf_t l;
  >    mpf_init(l);
  > 
  >    gmp_printf ("%.*Ff \n", 5, a);		--- 0.70000
  >    gmp_printf ("%.*Ff \n", 5, b);		--- 1.00000
  > 
  >    mpf_div(l, a, b);
  >    gmp_printf ("%.*Ff", 5, l);			--- 0.52502
  
  This example works on Mac OS X 10.7.4 with GMP 5.0.4 compiled directly
  from source, using the llvm-gcc 4.2.1 you indicate, and the example
  compiled using this compiler, clang 3.1 also from Xcode 4.3.2, and gcc
  4.7.0 compiled from source using this llvm-gcc.
  
If llvm-gcc compiles that code, it is more broken than I could ever have
imagined; I knew its code generator and optimiser were badly broken, but
now its parser thinks the above code is valid C...!

Here are the gcc 4.6 error messages:

  snippet.c:1:1: error: unknown type name 'mpf_t'
  snippet.c:2:1: warning: data definition has no type or storage class [enabled by default]
  snippet.c:2:1: warning: parameter names (without types) in function declaration [enabled by default]
  snippet.c:3:14: error: expected ')' before numeric constant
  snippet.c:4:1: error: unknown type name 'mpf_t'
  snippet.c:5:1: warning: data definition has no type or storage class [enabled by default]
  snippet.c:5:1: warning: parameter names (without types) in function declaration [enabled by default]
  snippet.c:6:14: error: expected ')' before numeric constant
  snippet.c:7:1: error: unknown type name 'mpf_t'
  snippet.c:8:1: warning: data definition has no type or storage class [enabled by default]
  snippet.c:8:1: warning: parameter names (without types) in function declaration [enabled by default]
  snippet.c:10:13: error: expected declaration specifiers or '...' before string constant
  snippet.c:10:25: error: expected declaration specifiers or '...' before numeric constant
  snippet.c:10:28: error: expected declaration specifiers or '...' before 'a'
  snippet.c:10:33: error: expected identifier or '(' before '--' token
  snippet.c:11:33: error: expected identifier or '(' before '--' token
  snippet.c:14:13: error: expected declaration specifiers or '...' before string constant
  snippet.c:14:22: error: expected declaration specifiers or '...' before numeric constant
  snippet.c:14:25: error: expected declaration specifiers or '...' before 'l'
  snippet.c:14:31: error: expected identifier or '(' before '--' token

(It was a mistake to allow the reporter messages to the "bugs" mailing
list.  We will be more strict in the future, since information free bug
reports invariably waste lots of volunteer time and lead nowhere.)

-- 
Torbjörn


More information about the gmp-bugs mailing list