From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 75E973858CDB; Thu, 13 Jul 2023 17:09:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75E973858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689268193; bh=MfU2DxS4fbg67GY1iICDOft42dekHeBf0jif1qt98P4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JNep/ZD/+ii+pYPHf6rvw/LTpg9Gc2zm0Ds0dwzPUTPrbgPO3FYMmsMsKe6Cmp5QX hhVFgK+ZXZJ/jJWa5H1TZx9xwaQckb9Fcvl+NNOsnil69SB4lBy9YQ5w+WnIXjz1XQ aRFCFetbNlMU74JicO1J8adXivKQjiRitO6DmXJQ= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110653] Support std::stoi etc. without C99 APIs Date: Thu, 13 Jul 2023 17:09:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110653 --- Comment #5 from Jonathan Wakely --- (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).=C2=A0 hpux11.11 has both > strtod and strtold.=C2=A0 strtold is checked for: >=20 > /* Define to 1 if you have the `strtof' function. */ > /* #undef HAVE_STRTOF */ >=20 > /* 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 ev= en 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 : using ::strtod; using ::strtol; using ::strtoul; I'm testing this, which should define std::stof and std::stold for hpux11.1= 1: --- 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 =3D 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 =3D 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 =3D 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 =3D 0) { return std::stod(__str, __idx); } -#endif // _GLIBCXX_USE_C99_STDLIB +#endif // DR 1261. Insufficent overloads for to_string / to_wstring=