From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uKc/Bv1z317RJwAA0tVLHw (envelope-from ) for ; Tue, 09 Jun 2020 11:35:25 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id KLLxAf1z316SagAAbx9fmQ (envelope-from ) for ; Tue, 09 Jun 2020 11:35:25 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 790CA9401CB for ; Tue, 9 Jun 2020 11:35:24 +0000 (UTC) Received: from localhost ([::1]:58010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jicXL-0006NY-6O for larch@yhetil.org; Tue, 09 Jun 2020 07:35:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jiapd-0005bv-B1 for guix-devel@gnu.org; Tue, 09 Jun 2020 05:46:10 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jiapa-0004Ld-0h for guix-devel@gnu.org; Tue, 09 Jun 2020 05:46:08 -0400 Received: by mail-wr1-x433.google.com with SMTP id y17so20507699wrn.11 for ; Tue, 09 Jun 2020 02:46:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=5AiOye5H6XSxlRHLuLkZPLb8a61zJJuEax0OX7fH0LE=; b=CST+vW9ZVUD5Lbp2BB0xSzB633Wi1v5K3M/s485yYDKUPOsX3uAUdh+wd8Y8xBxpeF +ZHHd0ZObhbDTlFCTgdXH2lu8Fhh3aOnXGkHii7WkEv7TJp+U2hZLEZOPN/0OerTWEMV 0wyVcfl9hzD3rBO3mgWOwG+7OqG34w1aZ6ENtV0EZTET0FLKwreYxB7aE0NrcUlJFpNd 4WWvokKfCbiWFIB91HtQN00StDxe4CB51xXgN053ZQ9Sc+UMZSePr4WudzSLhiPiNUJh 4z1LUG4C8J4ejv+CcGxNauwl3aO7IIBbaveQV+fNPoofH6VY1+J6v1zBJm07kFZKGo/R 3mxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5AiOye5H6XSxlRHLuLkZPLb8a61zJJuEax0OX7fH0LE=; b=mFT8vlOLvv7GYG9PMWJeoSDSuqd0CVwtvYKKEEC8UBJkadfGgAP7r0wXZdlLnQ2lRw 3A6Uq3pvTZtt9hmGlf/CH271XAJzYCwRkr4ehcpv6VQ+of64v1EL/DZrv73LzdmF17+V 6D5R42M1Yz5MLZC8GpXKTWDGkohG5Nhk1pz02GDghNYrhPMU/qmU+FFf7iMbwAEXReQU AkNp7yj4UckIk1X7vBzU+En7aLAg3t2hZxu5AbfOTeyIYu8D1R754vj/VuZeOVqC1ePH IK4KCGJBZvH/oab9jQUn8gm7ZcMHzpBygG6lLKJDjTnT46H/sDwT+HS4pLLRIjUvHZqO +elQ== X-Gm-Message-State: AOAM530OrSGSdEuCXLdVlytEpcKr/Im96K8fhPGssCrmQYBgp6zxEaae /1vkRmu3w6Mp4Oisy6JlTRD3h9YqUWknzzyFpQoaxHoWJUk= X-Google-Smtp-Source: ABdhPJyXO0e80CynAyRBkMchoi5WXM1pFYdSOHY648HpE0z+OFTfOfCqMzMfISLDGz9EtP/CbA6MzMTlTh7NWGVhR4k= X-Received: by 2002:a5d:6b81:: with SMTP id n1mr3366974wrx.411.1591695963271; Tue, 09 Jun 2020 02:46:03 -0700 (PDT) MIME-Version: 1.0 From: Erik Garrison Date: Tue, 9 Jun 2020 11:45:52 +0200 Message-ID: Subject: gcc-10 toolchain does not include string to numeric conversion functions like std::stoull To: guix-devel@gnu.org Content-Type: multipart/alternative; boundary="0000000000007b352b05a7a398f1" Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=erik.garrison@gmail.com; helo=mail-wr1-x433.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URI_HEX=1.122 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Tue, 09 Jun 2020 07:35:05 -0400 X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=CST+vW9Z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: KcsYeaBrEfJb --0000000000007b352b05a7a398f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello guix-devel, I've run into a quirk in the various gcc toolchains that seems somewhat unique to guix builds of them. I'd like to understand if this is intentional. Initially, I found that string to numeric conversion functions that are enabled by _GLIBCXX_USE_C99_STDLIB are not available on guix gcc toolchains for gcc 8, 9, and 10. This is a minimal test case to reproduce the problem: Code: #include #include uint64_t _parse_number(std::string::const_iterator& c, const std::string::const_iterator& end) { std::string::const_iterator s =3D c; while (c !=3D end and isdigit(*c)) ++c; if (c > s) { return std::stoull(std::string(s,c)); } else { return 0; } } int main(int argc, char** argv) { std::string s(argv[1]); std::string::const_iterator b =3D s.begin(); std::string::const_iterator e =3D s.end(); std::cout << _parse_number(b, e) << std::endl; return 0; } Compiling with (g++ --version =3D=3D 10.1.0), /gnu/store/3kvnslc16sy7kwi2c5r7r5k6bbv2p03f-gcc-toolchain-10.1.0/bin/g++ g++ test-stoull.cpp -o test-stoull Yields this error: test-stoull.cpp: In function =E2=80=98uint64_t _parse_number(std::__cxx11::basic_string::const_iterator&, const const_iterator&)=E2=80=99: test-stoull.cpp:13:33: error: invalid initialization of reference of type =E2=80=98const wstring&=E2=80=99 {aka =E2=80=98const std::__cxx11::basic_st= ring&=E2=80=99} from expression of type =E2=80=98std::string=E2=80=99 {aka =E2=80=98std::__cxx11= ::basic_string=E2=80=99} 13 | return std::stoull(std::string(s,c)); | ^~~~~~~~~~~ In file included from /home/erikg/.guix-profile/include/c++/string:55, from /home/erikg/.guix-profile/include/c++/bits/locale_classes.h:40, from /home/erikg/.guix-profile/include/c++/bits/ios_base.h:41, from /home/erikg/.guix-profile/include/c++/ios:42, from /home/erikg/.guix-profile/include/c++/ostream:38, from /home/erikg/.guix-profile/include/c++/iostream:39, from test-stoull.cpp:1: /home/erikg/.guix-profile/include/c++/bits/basic_string.h:6697:25: note: in passing argument 1 of =E2=80=98long long unsigned int std::__cxx11::stoull(= const wstring&, std::size_t*, int)=E2=80=99 6697 | stoull(const wstring& __str, size_t* __idx =3D 0, int __base =3D = 10) | ~~~~~~~~~~~~~~~^~~~~ I understand that there might be concern about my particular .guix-profile, but it's possible to reproduce this in containers. I can provide more test cases if needed, but I just wanted to clarify in general what I'm seeing. This behavior appears to be similar to this issue: http://freebsd.1045724.x6.nabble.com/base-gcc-and-GLIBCXX-USE-C99-td5781697= .html. It's also similar to this report, https://stackoverflow.com/questions/40779611/g-compile-error-invalid-initia= lization-of-reference-of-type-stdstod . It may be more correct to require wstring in these kinds of conversions. However, I'm concerned that if gcc is built differently in guix than it typically is in other distributions, we will need to patch many libraries when building them on guix. It's probably better to match typical expectations of developers about the behavior of gcc. Thanks in advance, Erik --0000000000007b352b05a7a398f1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello guix-devel,

I've run into a q= uirk in the various gcc toolchains that seems somewhat unique to guix build= s of them. I'd like to understand if this is intentional.
Initially, I found that string to numeric conversion functions = that are enabled by=C2=A0_GLIBCXX_USE_C99_STDLIB are not available on guix = gcc toolchains for gcc 8, 9, and 10.

This is a min= imal test case to reproduce the problem:

Code:

#include <i= ostream>
#include <string>

uint64_= t _parse_number(std::string::const_iterator& c, const std::string::cons= t_iterator& end) {
=C2=A0 =C2=A0 std::string::const_iterator s =3D c= ;
=C2=A0 =C2=A0 while (c !=3D end and isdigit(*c)) ++c;
=C2=A0 =C2=A0= if (c > s) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return std::stoull(std::str= ing(s,c));
=C2=A0 =C2=A0 } else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return = 0;
=C2=A0 =C2=A0 } =C2=A0
}

int main(int argc, char** argv) {<= br>=C2=A0 =C2=A0 std::string s(argv[1]);
=C2=A0 =C2=A0 std::string::cons= t_iterator b =3D s.begin();
=C2=A0 =C2=A0 std::string::const_iterator e = =3D s.end();
=C2=A0 =C2=A0 std::cout << _parse_number(b, e) <&l= t; std::endl;
=C2=A0 =C2=A0 return 0;
} =C2=A0

Compiling with= (g++ --version =3D=3D 10.1.0), /gnu/store/3kvnslc16sy7kwi2c5r7r5k6bbv2p03f= -gcc-toolchain-10.1.0/bin/g++

g++ test-stoull.cpp -o test-sto= ull

Yields this error:

test-stoull.cpp: In = function =E2=80=98uint64_t _parse_number(std::__cxx11::basic_string<char= >::const_iterator&, const const_iterator&)=E2=80=99:
test-sto= ull.cpp:13:33: error: invalid initialization of reference of type =E2=80=98= const wstring&=E2=80=99 {aka =E2=80=98const std::__cxx11::basic_string&= lt;wchar_t>&=E2=80=99} from expression of type =E2=80=98std::string= =E2=80=99 {aka =E2=80=98std::__cxx11::basic_string<char>=E2=80=99}=C2=A0 =C2=A013 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 return std::stoull(std::stri= ng(s,c));
=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 ^= ~~~~~~~~~~
In file included from /home/erikg/.guix-profile/include/c++/s= tring:55,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= from /home/erikg/.guix-profile/include/c++/bits/locale_classes.h:40,
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from /home/erikg= /.guix-profile/include/c++/bits/ios_base.h:41,
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from /home/erikg/.guix-profile/includ= e/c++/ios:42,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0from /home/erikg/.guix-profile/include/c++/ostream:38,
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from /home/erikg/.guix-= profile/include/c++/iostream:39,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0from test-stoull.cpp:1:
/home/erikg/.guix-profil= e/include/c++/bits/basic_string.h:6697:25: note: in passing argument 1 of = =E2=80=98long long unsigned int std::__cxx11::stoull(const wstring&, st= d::size_t*, int)=E2=80=99
=C2=A06697 | =C2=A0 stoull(const wstring& = __str, size_t* __idx =3D 0, int __base =3D 10)
=C2=A0 =C2=A0 =C2=A0 | = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0~~~~~~~~~~~~~~~^~~~~

I understand that there might be concern about my particular .guix= -profile, but it's possible to reproduce this in containers. I can prov= ide more test cases if needed, but I just wanted to clarify in general what= I'm seeing.


It may= be more correct to require wstring in these kinds of conversions. However,= I'm concerned that if gcc is built differently in guix than it typical= ly is in other distributions, we will need to patch many libraries when bui= lding them on guix. It's probably better to match typical expectations = of developers about the behavior of gcc.

Thanks in= advance,

Erik
--0000000000007b352b05a7a398f1--