GNU MPFR version 3.0.0 (released on 10 June 2010)

[download] [documentation] [bugs] [changes] [platforms] [timings]

The boudin aux pommes release.

MPFR 3.0.0 requires GMP 4.1.0 or higher (GMP 4.2.3 or higher is recommended).

Note: the bug-fix release MPFR 3.0.1 is available. Please upgrade!


The MPFR 3.0.0 source can be downloaded in the following archive formats:

MPFR is also available via third-party packages and ports.



The bugs listed below have been fixed (latest update: 2010-11-10). The patches are distributed under the same license as this version of MPFR, that is, the GNU Lesser General Public License (GNU Lesser GPL), version 3 or later.

The following instructions are for Linux and may be similar for other operating systems. You can apply the patches in several ways:

With the first two ways, the PATCHES file is modified, so that one can know what patches have been applied, using the mpfr_get_patches function. Moreover a suffix is added to the version string, but note that for practical reasons, not all the files where the version appears are patched; thus one can also track applied patches with the MPFR_VERSION_STRING macro (header) and the mpfr_get_version function (library). However, if some patches are not applied or if patches are applied in a different order, then the patch command will fail to update some chunks, so that the suffix is not always reliable for patches.

Note: These patches are in unified diff format and some vendors' patch commands cannot deal with them; in this case, please use GNU patch (it may already be installed on your system, e.g. as /usr/local/bin/patch or gpatch).

Fixed bugs, with patches:

  1. The integer value returned by the mpfr_out_str function is incorrect on NaN and infinities. Moreover output errors are not handled, and if such an error occurs, the return value is incorrect (it should have been 0). These bugs are fixed by the mpfr_out_str patch (which also provides additional tests of mpfr_out_str).
  2. On some environments such as Solaris with Sun's compiler, MPFR is not built correctly; this can be seen with make check, where a typical error is the symbol alloca being undefined. The real reason of this failure is that HAVE_ALLOCA_H is not defined. This problem has been introduced in MPFR 3.0.0. It is fixed in the alloca patch.
  3. The underflow detection in mpfr_gamma is incorrect. A possible consequence is that the function can freeze. This bug is fixed by the gamma_underflow patch (which also provides a testcase for 32-bit machines).
  4. In the mpfr_cmp_ui macro for GCC-based compilers, when the second argument is a constant expression with the value 0, the first argument is evaluated twice, making the behavior incorrect when the evaluation of the first argument yields side effects. The mpfr_cmp_si macro uses mpfr_cmp_ui, thus is also affected by this bug. Note that though mpfr_cmp_ui and mpfr_cmp_si are described as functions, they are also implemented as macros in mpfr.h (except in case of a bug like here, a macro implementation should not introduce a difference in the behavior).

    A much less important problem is that the mpfr_cmp_si and mpfr_set_si macros for GCC-based compilers (from mpfr.h) can yield warnings when user code is compiled with the -Wconversion option.

    These macros mpfr_cmp_ui, mpfr_cmp_si, mpfr_set_ui and mpfr_set_si for GCC-based compilers can have an incorrect behavior if user code with undefined behavior requires to behave according to some non-standard C extension (like with the use of the -fwrapv GCC option) and the call is done with an argument that requires an implicit conversion to unsigned long or long.

    All these problems are fixed by the mpfr_cmp/set_ui/si patch (which also provides a testcase for the first problem).

  5. The tcan_round test can fail due to a bug in the test, that can occur now that the mpfr_prec_t type is signed. This problem is fixed by the tcan_round patch.
  6. In some special cases, the subtraction code can return a result that is not correctly rounded (both mpfr_add and mpfr_sub functions call this code, depending on the signs of the inputs). It can possibly yield undefined behavior, as the result may not be normalized (if MPFR had been built with the --enable-assert configure option, an assertion failure occurs in such a case). This bug cannot occur if the input and output precisions of the subtraction are the same, but it can also be triggered by functions that call mpfr_add or mpfr_sub with different precisions, e.g. by mpfr_fma and mpfr_fms. All the MPFR versions up to version 3.0.0 are affected. This bug is fixed by the mpfr_sub1 patch (which also provides testcases for mpfr_sub and mpfr_fma). This patch has been backported for older MPFR versions.
    [mpfr_sub1 bug report on the tracker]
  7. The mpfr_set_ld function is buggy on very small values. This bug cannot occur on platforms where the long double type corresponds to x87 extended precision or less, but it has been observed on a platform with quadruple precision. This bug is fixed by the mpfr_set_ld patch.
    [mpfr_set_ld bug report on the tracker]
  8. The mpfr_cmp/set_ui/si patch introduced two minor problems: First, if the user defines a macro with the same name as some keywords (which is implicitly discouraged), the behavior can be incorrect (compilation failure of the user code, wrong results...); this problem was already there for some other macros. Second, some usual type checking was no longer done; for instance, passing a pointer instead of an integer was no longer regarded as an error at compilation time. The macros patch fixes these problems. Note however that defining a macro with the name do, while or sizeof is still forbidden, and other restrictions may be added in the future (unless MPFR_USE_NO_MACRO has been defined).

Bugs that are fixed in the trunk and in the 3.0 branch (for the future MPFR 3.0.1 version), with changesets for the 3.0 branch:

Other bugs: please see the tracker and the BUGS file.

Note: if you are trying to build GCC and get the error header files gmp-impl.h and longlong.h not found, please look at GCC bug 44455. This problem is a consequence of a correction in the detection of a GMP build directory.

Changes from versions 2.4.* to version 3.0.0

Platforms Known to Support MPFR

MPFR 3.0.0 has been successfully compiled and checked on the following platforms:

Back to the MPFR page.