On Thu, 30 Mar 2017, Vincent Lefevre wrote:

On 2017-03-30 10:52:33 +0100, Claude Heiland-Allen wrote:
The failing source code is:

  /* EOF for no matching */
  {
    char buf[128];
    ret = gmp_sscanf ("   ", "%s", buf);
    ASSERT_ALWAYS (ret == EOF);
    ret = fromstring_gmp_fscanf ("   ", "%s", buf);
    ASSERT_ALWAYS (ret == EOF);
    if (option_libc_scanf)
      {
        ret = sscanf ("   ", "%s", buf);
        ASSERT_ALWAYS (ret == EOF);
        ret = fun_fscanf ("   ", "%s", buf, NULL);
        ASSERT_ALWAYS (ret == EOF);
      }
  }

Commenting out the asserts and 'if' and inserting debugging printf()
statements gives:

    gmp_sscanf() ret = 0
    fromstring_gmp_fscanf() ret = 0
    sscanf() ret = 0
     ^^^^^^^^^^^^^^^^
    fun_fscanf() ret = 0

The initial issue is the 0 returned by sscanf(). Then GMP is consistent
with the C implementation.

Though the C standard may be ambiguous, 0 is not possible as a return
value. Thus this is a bug in the C library (or compiler).

Could the macro __USE_MINGW_ANSI_STDIO be relevant?

--
Marc Glisse
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to