https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110653
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to dave.anglin from comment #3) > On 2023-07-13 9:46 a.m., redi at gcc dot gnu.org wrote: > > Dave, does this patch work for hppa64-hp-hpux11.11 ? > Yes. Great - pushed to trunk. > On hpux, double and long double have different representations (they are > same on linux). hpux11.11 has both > strtod and strtold. strtold is checked for: > > /* Define to 1 if you have the `strtof' function. */ > /* #undef HAVE_STRTOF */ > > /* Define to 1 if you have the `strtold' function. */ > #define HAVE_STRTOLD 1 Ah yes. That comes from libstdc++-v3/linkage.m4 which I think I've never even looked at before! > There doesn't seem to be a configure check for strtod. That's from C89 and we already assume that's available unconditionally e.g. for this code in <cstdlib>: using ::strtod; using ::strtol; using ::strtoul; I'm testing this, which should define std::stof and std::stold for hpux11.11: --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -4148,12 +4148,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 stod(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } -#if _GLIBCXX_USE_C99_STDLIB +#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOF // NB: strtof vs strtod. inline float stof(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); } +#endif +#if _GLIBCXX_USE_C99_STDLIB || _GLIBCXX_HAVE_STRTOLD inline long double stold(const string& __str, size_t* __idx = 0) { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); } @@ -4161,7 +4163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 inline long double stold(const string& __str, size_t* __idx = 0) { return std::stod(__str, __idx); } -#endif // _GLIBCXX_USE_C99_STDLIB +#endif // DR 1261. Insufficent overloads for to_string / to_wstring