mpz_set_si loses long long value on Windows
Vincent Lefevre
vincent at vinc17.net
Wed Jul 24 12:07:05 UTC 2019
On 2019-07-24 13:45:22 +0200, Torbjorn Granlund wrote:
> I think we should require C99 for GMP 7.
Unfortunately, that's not enough. One practical issue is the MS-Windows
environment (again) and the Microsoft runtime. We have the following in
MPFR's INSTALL file (note the mention of GMP):
3 - To avoid using the Microsoft runtime (which might not be conform to ISO C),
you can use the MinGW runtime package (which is an integral part of MinGW).
For example, with MinGW versions 3.15 and later you can get an
ISO-compliant printf() if you compile your application with either
'-ansi', '-posix' or '-D__USE_MINGW_ANSI_STDIO'. In order to have the
MPFR formatted output functions based on ISO-compliant printf(), you
need to compile GMP (not MPFR) with CC="gcc -D__USE_MINGW_ANSI_STDIO"
(since the standard printf modifiers %e, %Ld and %td are passed to GMP).
Not doing so may result in failures of some of the printf-related tests.
For instance, the following error on some Windows machine has been
reported:
https://sympa.inria.fr/sympa/arc/mpfr/2016-02/msg00053.html
Error in mpfr_vsprintf (s, "%e", ...);
expected: "-1.250000e+000"
got: "-1.250000e+00"
FAIL tsprintf.exe (exit status: 1)
The cause is that here the C functions vsnprintf and vsprintf used
internally in GMP do not produce the same output:
https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00045.html
https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00051.html
https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00053.html
Building MPFR with -D__USE_MINGW_ANSI_STDIO is currently useless except
for some error messages in the test suite.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-bugs
mailing list