assertion failure in snprntffuns.c:79 for i686-w64-mingw32

Niels Möller nisse at
Fri Jan 10 07:44:13 UTC 2020

Vincent Lefevre <vincent at> writes:

> Under Debian/unstable, I've configured GMP with:
>   ./configure --host=i686-w64-mingw32 --disable-shared --enable-assert
> but "make check LOG_COMPILER=wine" gives:
> FAIL: t-printf
> ==============
> snprntffuns.c:79: GNU MP assertion failed: strlen (d->buf) == avail-1
> FAIL t-printf.exe (exit status: 3)
> The failing code is
>       ret = vsnprintf (d->buf, avail, fmt, ap);
>       if (ret == -1)
>         {
>           ASSERT (strlen (d->buf) == avail-1);
>           ret = avail-1;
>         }

Does it make a difference if you add CPPFLAGS=-D__USE_MINGW_ANSI_STDIO
to the configuration?

> I don't understand the ASSERT. A return value of -1 means an output
> error, so that you cannnot deduce anything about the contents stored
> in d->buf.

Non-standard versions of snprintf returned -1 for truncation (including
old glibc, and likely windows libc too). And the way I read the ASSERT,
it says that truncation is the only expected reason for vsnprintf to
return -1. What was fmt? It would be helpful to understand the reason
for the -1 return in the failing case.

> /* Define to 1 if you have the `vsnprintf' function and it works properly. */
> #define HAVE_VSNPRINTF 1

I guess it's hard for configure to check for proper return value when cross


Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list