Package: libmpfr-dev
Version: 3.0.0-2
Severity: normal
Tags: upstream fixed-upstream

The attached C source shows a bug in the mpfr_cmp_ui macro.
It is fixed by patch 4:

  http://www.mpfr.org/mpfr-3.0.0/#p4

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash

Versions of packages libmpfr-dev depends on:
ii  libgmp3-dev               2:4.3.2+dfsg-1 Multiprecision arithmetic library 
ii  libmpfr4                  3.0.0-2        multiple precision floating-point 

libmpfr-dev recommends no packages.

Versions of packages libmpfr-dev suggests:
ii  libmpfr-doc                   3.0.0-2    multiple precision floating-point 

-- no debconf information
/* Testcase for http://www.mpfr.org/mpfr-3.0.0/#p4
 *
 * OK with:
 *   gcc -Wall -std=c99 bug-cmp_ui-macro.c -lmpfr -lgmp -DMPFR_USE_NO_MACRO
 * Possible crash without -DMPFR_USE_NO_MACRO and with -DN=<large_value>.
 * Bug fixed on 2010-09-01 in r7116 (trunk) and r7117 (3.0 branch).
 */

#include <stdio.h>
#include <mpfr.h>

#ifndef N
# define N 4
#endif

int main (void)
{
  mpfr_t t[N];
  mpfr_ptr p;
  int i, err = 0;

  for (i = 0; i < N; i++)
    {
      mpfr_init2 (t[i], 64);
      mpfr_set_ui (t[i], i & 1, MPFR_RNDN);
    }

  p = (mpfr_ptr) t;
  for (i = 0; i < N; i++)
    if ((mpfr_cmp_ui (p++, 0) != 0) != (i & 1))
      {
        printf ("Error for i = %d\n", i);
        err = 1;
      }

  for (i = 0; i < N; i++)
    mpfr_clear (t[i]);

  return err;
}

/* $Id: bug-cmp_ui-macro.c 39212 2010-09-07 15:50:55Z vinc17/xvii $ */

Reply via email to