GMP crashes when using gmp_scanf to scan an mpf_t.

Marc Glisse marc.glisse at inria.fr
Thu Aug 24 15:32:26 UTC 2017


On Thu, 24 Aug 2017, Piotr Olszewski wrote:

> The crash happened when I tried to run a piece of code from the manual (11.1):
>
> /* to read say "topleft (1.55,-2.66)" */
> mpf_t x, y;
> char buf[32];
> gmp_scanf ("%31s (%Ff,%Ff)", buf, x, y);
>
> I placed it in a main function and added a line to print the scanned information like this:
>
> #include <gmp.h>
> int main(void)
> {
>  /* to read say "topleft (1.55,-2.66)" */
>  mpf_t x, y;
>  char  buf[32];
>  gmp_scanf ("%31s (%Ff,%Ff)", buf, x, y);
>  gmp_printf("%s (%Ff,%Ff)\n", buf, x, y);
>  return 0;
> }

This is not a snippet meant to be copy-pasted, the declarations are there 
to show the types of the arguments, but you need to mpf_init the variables 
as usual.

-- 
Marc Glisse


More information about the gmp-bugs mailing list