printf/repl-vsnprintf.c bug (was: GMP|MPIR|MPFR assertions)

paul zimmermann Paul.Zimmermann at inria.fr
Thu Jan 18 14:16:43 UTC 2018


> > printf/repl-vsnprintf.c seems buggy for floating-point specifiers
> > (EeGgFf). Replace "break" by "goto next" (2 occurrences)?
> 
> Proposed patch attached. Not tested.

here is a test case to reproduce the issue (you have to test it on a system that
doesn't have vsnprintf, or only has a broken one, or define HAVE_VSNPRINTF to 0 in
config.h):

#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <gmp.h>

int test(const char *fmt,...)
{
  va_list args;
  char *s = NULL;
  int size;

  va_start(args,fmt);
  size = gmp_vasprintf(&s, fmt, args);
  printf("size=%d s='%s'\n", size, s);

  return 0;
}

int main(void)
{
  char *fmt = "%f %Zd";
  mpz_t z;
  float f = 17.0;
  mpz_init_set_ui (z, 42);
  test(fmt, f, z);
  mpz_clear (z);
}

$ ./a.out 
repl-vsnprintf.c:358: GNU MP assertion failed: 0
Aborted (core dumped)

Paul


More information about the gmp-bugs mailing list