[Bug libstdc++/64054] 27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc FAILs

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 25 15:20:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64054

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks - so it looks as though the problem is in std::stod which is pretty
simple, and can be reduced to:

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
      double d;

      char* endptr;
      errno = 0;
      const char* str = "0x1.1000000000000p+8";
      const double tmp = strtod(str, &endptr);

      if (endptr == str) {
        puts("no characters consumed");
    return 1;
      }
      else if (errno == ERANGE) {
        puts("ERANGE");
    return 2;
      }
      else if (*endptr) {
        printf("stopped at '%c'\n", *endptr);
        return 3;
      }
      else
    d = tmp;

     printf("%f %a\n", d, d);
}

Maybe Solaris' strtod() doesn't support hex floats in C++ code, so it will
print "stopped at 'x'"



More information about the Gcc-bugs mailing list