https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68737
--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> --- I don't think we care about glibc < 2.0.6 though. __max_digits * 4 is not enough for: std::cout << std::fixed << std::numeric_limits<long double>::max(); That needs 4940 bytes, but we don't want to unconditionally alloca that amount. Maybe: --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -1008,6 +1008,11 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf, __v); +#ifdef __hpux + if (__len == -1) + __len = __cs_size = 5000; +#endif + // If the buffer was not large enough, try again with the correct size. if (__len >= __cs_size) { @@ -1020,6 +1025,11 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf, __v); } + +#ifdef __hpux + if (__len == -1) + return __s; +#endif #else // Consider the possibility of long ios_base::fixed outputs const bool __fixed = __io.flags() & ios_base::fixed;