mpf_class x("+0.73") aborts

Torbjorn Granlund tg at
Fri May 23 11:08:35 CEST 2008

"Pasquale Tricarico" <tricaric at> writes:

  If you include a statement in your code such as
  #include <gmpxx.h>
  mpf_class x("+0.73");
  or any other string in the form "+XYZ", it will abort at runtime with:
  terminate called after throwing an instance of 'std::invalid_argument'
    what():  mpf_set_str
  I believe that a signed string, with a plus, should be a valid
  argument. The same with a minus instead of a plus is valid, as it is
  an unsigned value, of course.
  Comments and solutions welcome.
None of the GMP input function accept a leading +, and gmpcc.h just
inherits its from mpz_set_str.

We will consider changing this for a future GMP release.


More information about the gmp-bugs mailing list