[Patch] First step towards fast parsing of float types

Paolo Carlini pcarlini@unitus.it
Thu Dec 18 18:08:00 GMT 2003


... interesting, very interesting...

The expected result for this kind of situation:

> + iss.str("3e.");
> + iss.clear();
> + err = ios_base::goodbit;
> + end = ng.get(iss.rdbuf(), 0, iss, err, d);
> + VERIFY( err == ios_base::failbit );
> + VERIFY( *end == '.' );

It's *not* a regression, but it's actually wrong! The correct result is just
3.0 with no error, because, basing on the standard, if no exponent digits
are seen, the exponent is assumed to be zero!

v3 gets this wrong because of this:

  double __d = __strtod_l(__s, &__sanity, __cloc);
  if (__sanity != __s && *__sanity == '\0' && errno != ERANGE)
                      ^^^^^^^^^^^^^^^^^^^^
    __v = __d;
  else
    __err |= ios_base::failbit;

The additional check is *incorrect* because strtod returns __sanity pointing
to 'e', *not* to '\0'! And this is perfectly OK! Indeed d == 3.0 and
errno is not set ERANGE.

Therefore, we must definitely remove the additional bogus check.

Incredible that nobody *ever* noticed this *bad* regression vs v2!

So... I'm preparing a set of additional testcases to go with the additional
changes to c_locale.cc. Will post a complete patch soon...

Paolo.



More information about the Libstdc++ mailing list