Strange behavior of mpf_inp_str
Ronald Bruck
bruck at usc.edu
Sun Feb 21 21:36:31 CET 2010
Paul Zimmerman emailed me the following:
> Ron,
>there were several issues with mpf_set_str and mpf_inp_str in previous GMP
>releases. See http://gmplib.org/oldrel/. Please make sure you are using
>GMP 5.0.1. To check that, compile and run the following program with the
>same compiler command as the program giving the strange behaviour (or even
>better include this in your program):
>#include "gmp.h"
>int
>main()
>{
> printf ("GMP library: %s\n", gmp_version);
>printf ("GMP include: %d.%d.%d\n", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
> __GNU_MP_VERSION_PATCHLEVEL);
>}
I had already overwritten the old installation with the new OpenSuSE 11.2, and installed GMP-5.0.1 with no problems, but when I compiled and ran the program I discovered I was using libs 4.3.1 and includes 5.0.1. (And somewhat mysteriously, mpf_inp_str had started working again.)
Looking at the libs again, I found libgmp.a and its relatives also in /usr/lib and /usr/lib64, as well as /usr/local/lib and /usr/local/lib64, where I wanted them. libgmp.a was also in a mysterious /usr/lib/engine directory. When I removed those files and recompiled, I find I'm now using 5.0.1 throughout.
Now, I vaguely recall that SuSE installs GMP (without asking), and that's where the extra files probably come from.
Why mpf_inp_str worked in the 11.2 configuration, and not the old 11.1 configuration, I have no idea. "Doctor, it hurts
when I do this." "Then don't do that."
SuSE 11.2 ships with gcc-4.4.1, and life is not perfect: gcc complained that it ran out of memory when I tried to compile pari-2.3.5. (It was trying to use all 83GB of main memory and swap.) I downgraded to gcc-4.3.4 and it worked.
Many thanks to all for helping me resolve this. I've decided to put Paul's code in all my programs, with output to stderr and activated by a command-line switch (maybe '-d'). Not that I'm paranoid...
--
Ron Bruck
More information about the gmp-bugs
mailing list