[RFC] sscanf vs ERANGE vs finitel

Paolo Carlini pcarlini@suse.de
Sat Mar 20 16:02:00 GMT 2004


Hi everyone,

I'd like the understand the **long** standing failure of
27_io/basic_istream/extractors_arithmetic/char/12.cc on some
platforms and in order to do that I'm looking again at our generic
__convert_to_v(long double&).

Something puzzling is this:

#if defined(_GLIBCXX_USE_C99)
      char* __sanity;
      errno = 0;
      long double __ld = strtold(__s, &__sanity);
      if (__sanity != __s && errno != ERANGE)
        __v = __ld;
#else
      typedef char_traits<char>::int_type int_type;
      long double __ld;
      errno = 0;
      int __p = sscanf(__s, "%Lf", &__ld);
      if (errno == ERANGE)
        __p = 0;
#ifdef _GLIBCXX_HAVE_FINITEL
      if ((__p == 1) && !finitel (__ld))
        __p = 0;
#endif
      if (__p && static_cast<int_type>(__p) != char_traits<char>::eof())
        __v = __ld;
#endif

Why bother checking finitel? Is it really possible that sscanf("%Lf")
doesn't set ERANGE, still !finitel is true??

Thanks,
Paolo.

P.S. By the way, is _GLIBCXX_USE_C99 defined on aix5.1??



More information about the Libstdc++ mailing list