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

2020-01-09 Thread Niels Möller
Vincent Lefevre  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
compiling.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


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

2020-01-09 Thread Vincent Lefevre
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;
}

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.

The first error occurs in check_limb

  s = mpz_get_str (NULL, 10, z);
  check_one (s, "%Mu", limb);
  (*__gmp_free_func) (s, strlen (s) + 1);

for i = 7, i.e. with limb = 127.

Note that config.h contains

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

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs