From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5DC833858D1E; Thu, 13 Jul 2023 15:14:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DC833858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689261243; bh=1IDiSyog+NniIXj3BEpmTAIw0mZg21tJuk9iZo61NAg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=etWJ8dBan0iaGHXUknUeE78QHBTLp4kImTWHsNZa6mg+RrbAyOnFV55MX90WGClKb cQdDTkwYwcBv8yXKPbs79xlcB2AfjZmXPNvlJ8ezJkDJZbPppJ79ltYebM87zi4UwH i6h5S1JhYGQSsPbq1G1cpuDNAIzbyLWBppYYXy04= From: "dave.anglin at bell dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110653] Support std::stoi etc. without C99 APIs Date: Thu, 13 Jul 2023 15:14:02 +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: dave.anglin at bell dot net 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 #3 from dave.anglin at bell dot net --- On 2023-07-13 9:46 a.m., redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110653 > > --- Comment #2 from Jonathan Wakely --- > Created attachment 55534 > --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55534&action=3Ded= it > libstdc++: std::stoi etc. do not need C99 support > > Dave, does this patch work for hppa64-hp-hpux11.11 ? Yes. > > It should allow you to compile + run the code below: > > #include > int main() > { > std::string z =3D "0"; > return std::stoi(z) + std::stol(z) + std::stoul(z) + std::stoll(z) > + std::stoull(z) + std::stod(z); > } The above code compiles and runs successfully on hppa64-hp-hpux11.11 with t= he patch. > > I'm not sure if double and long double are the same representation on this > target, but if they are then std::stold("0.0") should work too. Adding std::stold("0.0") to test, we get: bash-5.1$ gcc/xg++ -Bgcc/ -o xxx xxx.cc -I./hppa64-hp-hpux11.11/libstdc++-v3/include=20 -I./hppa64-hp-hpux11.11/libstdc++-v3/include/hppa64-hp-hpux11.11 -I/home/dave/gnu/gcc/gcc/libstdc++-v3/libsupc++=20 -Lhppa64-hp-hpux11.11/libstdc++-v3/src/.libs -O2 xxx.cc: In function 'int main()': xxx.cc:6:48: error: 'stold' is not a member of 'std' =C2=A0=C2=A0=C2=A0 6 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 + s= td::stoull(z) + std::stod(z) + std::stold("0.0"); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 ^~~~~ xxx.cc:2:1: note: 'std::stold' is defined in header ''; this is probably fixable by adding '#include ' =C2=A0=C2=A0=C2=A0 1 | #include =C2=A0 +++ |+#include =C2=A0=C2=A0=C2=A0 2 | int main() On hpux, double and long double have different representations (they are sa= me on linux).=C2=A0 hpux11.11 has both strtod and strtold.=C2=A0 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 There doesn't seem to be a configure check for strtod.=