Mentions légales du service

Commit 3cd39bc0 authored by Vincent Lefèvre's avatar Vincent Lefèvre
Browse files

Fix mpfr_custom_get_kind() macro bug.

* src/mpfr.h: in the mpfr_custom_get_kind() macro, changed mpfr_ptr to
  mpfr_srcptr for _x to agree with the function prototype, in order to
  avoid a compilation failure of user code in some cases. This bug was
  introduced by commit 9f94e031, which
  introduced the temporary variable _x to avoid an incorrect number of
  evaluations of the x argument.
* tests/tstckintc.c: improved the tests to detect this bug.

This should fix mpfr bug #1.

Bug initially reported by FX Coudert:
  https://github.com/CGAL/cgal/issues/7064

It affects Fedora Linux:
  https://bugzilla.redhat.com/show_bug.cgi?id=2144197

(cherry picked from commit 0ce17bae)
parent 86bd977a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1027,7 +1027,7 @@ __MPFR_DECLSPEC int mpfr_total_order_p (mpfr_srcptr, mpfr_srcptr);
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
#define mpfr_custom_get_kind(x)                                         \
  __extension__ ({                                                      \
    mpfr_ptr _x = (x);                                                  \
    mpfr_srcptr _x = (x);                                               \
    _x->_mpfr_exp >  __MPFR_EXP_INF ?                                   \
      (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (_x)                     \
      : _x->_mpfr_exp == __MPFR_EXP_INF ?                               \
+7 −3
Original line number Diff line number Diff line
@@ -295,14 +295,16 @@ static void
test_nan_inf_zero (void)
{
  mpfr_ptr val;
  mpfr_srcptr sval;  /* for compilation error checking */
  int sign;
  int kind;

  reset_stack ();

  val = new_mpfr (MPFR_PREC_MIN);
  sval = val;
  mpfr_set_nan (val);
  kind = (mpfr_custom_get_kind) (val);
  kind = (mpfr_custom_get_kind) (sval);
  if (kind != MPFR_NAN_KIND)
    {
      printf ("mpfr_custom_get_kind error: ");
@@ -380,6 +382,7 @@ static long *
dummy_set_si (long si)
{
  mpfr_t x;
  mpfr_srcptr px;  /* for compilation error checking */
  long *r = dummy_new ();
  int i1, i2, i3, i4, i5;

@@ -405,7 +408,8 @@ dummy_set_si (long si)
  MPFR_ASSERTN (i5 == 1);

  mpfr_set_si (x, si, MPFR_RNDN);
  r[0] = mpfr_custom_get_kind (x);
  px = x;
  r[0] = mpfr_custom_get_kind (px);

  /* Check that the type "void *" can be used in C, like with the function
     (forbidden in C++). Also check side effects. */