From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0B9C3858D33; Sun, 21 May 2023 10:02:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0B9C3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684663333; bh=5bActTkzDuZFYWVzXtO5LQXa1Lf+g3fTzIyjFqPga4U=; h=From:To:Subject:Date:From; b=q/W7tq6kVveH9LouFVObtS8Dm7dQakl05DTInRrKJ0Dzu7GZkOPV0IixefgWZfgoc JMU9Alz73LITzl3RNaIOG1hrJ2Xy3Dp4wZeYAKt7Ikj4YGH3IoyQchg+bXa7LIPwFb J2fKtjq1XgkIscG9sssIO+guYQTX4p7/9jf3dWzY= From: "br015 at umbiko dot net" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBsaWJzdGRjKysvMTA5OTIxXSBOZXc6IGMrKzE3L2Zsb2F0?= =?UTF-8?B?aW5nX2Zyb21fY2hhcnMuY2M6IGNvbXBpbGUgZXJyb3I6IOKAmGZyb21fY2hh?= =?UTF-8?B?cnNfc3RydG9k4oCZIHdhcyBub3QgZGVjbGFyZWQgaW4gdGhpcyBzY29wZQ==?= Date: Sun, 21 May 2023 10:02:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: br015 at umbiko dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109921 Bug ID: 109921 Summary: c++17/floating_from_chars.cc: compile error: =E2=80=98from_chars_strtod=E2=80=99 was not declared in= this scope Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: br015 at umbiko dot net Target Milestone: --- This was observed in 13.1.0, but code is the same as git master. Line numbe= rs and code snippets refer to git master.=20 /observed error/ Cross-compiling gcc 13.1 for a system without locales, libstdc++ fails to b= uild with the following error:=20 >Making all in c++17 >/bin/bash ../../libtool --tag CXX --tag disable-shared --mode=3Dcompile = /home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/./gcc/xgcc -s= hared-libgcc -B/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/buil= d/./gcc -nostdinc++ -L/home/data/buildroot.x86_64/build/host-gcc-final-13.1= .0/build/x86_64-buildroot-linux-uclibc/libstdc++-v3/src -L/home/data/buildr= oot.x86_64/build/host-gcc-final-13.1.0/build/x86_64-buildroot-linux-uclibc/= libstdc++-v3/src/.libs -L/home/data/buildroot.x86_64/build/host-gcc-final-1= 3.1.0/build/x86_64-buildroot-linux-uclibc/libstdc++-v3/libsupc++/.libs -B/h= ome/data/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/bin/ -B/home/d= ata/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/lib/ -isystem /home= /data/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/include -isystem = /home/data/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/sys-include = -I/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/libstdc++-v3/.= ./libgcc -I/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/x8= 6_64-buildroot-linux-uclibc/libstdc++-v3/include/x86_64-buildroot-linux-ucl= ibc -I/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/x86_64-= buildroot-linux-uclibc/libstdc++-v3/include -I/home/data/buildroot.x86_64/b= uild/host-gcc-final-13.1.0/libstdc++-v3/libsupc++ -std=3Dgnu++17 -nostdin= c++ -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -W= write-strings -Wcast-qual -Wabi=3D2 -fdiagnostics-show-location=3Donce -= ffunction-sections -fdata-sections -frandom-seed=3Dfloating_from_chars.lo = -fimplicit-templates -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFF= SET_BITS=3D64 -O2 -g0 -D_GNU_SOURCE -fcf-protection -mshstk -c -o floatin= g_from_chars.lo ../../../../../libstdc++-v3/src/c++17/floating_from_chars.cc >libtool: compile: /home/data/buildroot.x86_64/build/host-gcc-final-13.1.0= /build/./gcc/xgcc -shared-libgcc -B/home/data/buildroot.x86_64/build/host-g= cc-final-13.1.0/build/./gcc -nostdinc++ -L/home/data/buildroot.x86_64/build= /host-gcc-final-13.1.0/build/x86_64-buildroot-linux-uclibc/libstdc++-v3/src= -L/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/x86_64-bui= ldroot-linux-uclibc/libstdc++-v3/src/.libs -L/home/data/buildroot.x86_64/bu= ild/host-gcc-final-13.1.0/build/x86_64-buildroot-linux-uclibc/libstdc++-v3/= libsupc++/.libs -B/home/data/buildroot.x86_64/host/x86_64-buildroot-linux-u= clibc/bin/ -B/home/data/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc= /lib/ -isystem /home/data/buildroot.x86_64/host/x86_64-buildroot-linux-ucli= bc/include -isystem /home/data/buildroot.x86_64/host/x86_64-buildroot-linux= -uclibc/sys-include -I/home/data/buildroot.x86_64/build/host-gcc-final-13.1= .0/libstdc++-v3/../libgcc -I/home/data/buildroot.x86_64/build/host-gcc-fina= l-13.1.0/build/x86_64-buildroot-linux-uclibc/libstlibtool: compile: /home/= data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/./gcc/xgcc -shared-= libgcc -B/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/./gc= c -nostdinc++ -L/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/bui= ld/x86_64-buildroot-linux-uclibc/libstdc++-v3/src -L/home/data/buildroot.x8= 6_64/build/host-gcc-final-13.1.0/build/x86_64-buildroot-linux-uclibc/libstd= c++-v3/src/.libs -L/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/= build/x86_64-buildroot-linux-uclibc/libstdc++-v3/libsupc++/.libs -B/home/da= ta/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/bin/ -B/home/data/bu= ildroot.x86_64/host/x86_64-buildroot-linux-uclibc/lib/ -isystem /home/data/= buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/include -isystem /home/= data/buildroot.x86_64/host/x86_64-buildroot-linux-uclibc/sys-include -I/hom= e/data/buildroot.x86_64/build/host-gcc-final-13.1.0/libstdc++-v3/../libgcc = -I/home/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/x86_64-buil= droot-linux-uclibc/libstdc++-v3/include/x86_64-buildroot-linux-uclibc -I/ho= me/data/buildroot.x86_64/build/host-gcc-final-13.1.0/build/x86_64-buildroot= -linux-uclibc/libstdc++-v3/include -I/home/data/buildroot.x86_64/build/host= -gcc-final-13.1.0/libstdc++-v3/libsupc++ -std=3Dgnu++17 -nostdinc++ -D_GLIB= CXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qua= l -Wabi=3D2 -fdiagnostics-show-location=3Donce -ffunction-sections -fdata-s= ections -frandom-seed=3Dfloating_from_chars.lo -fimplicit-templates -D_LARG= EFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -O2 -g0 -D_GNU_= SOURCE -fcf-protection -mshstk -c ../../../../../libstdc++-v3/src/c++17/flo= ating_from_chars.cc -fPIC -DPIC -D_GLIBCXX_SHARED -o floating_from_chars.o >../../../../../libstdc++-v3/src/c++17/floating_from_chars.cc: In function = =E2=80=98std::from_chars_result std::from_chars(const char*, const char*, _= Float128&, chars_format)=E2=80=99: >../../../../../libstdc++-v3/src/c++17/floating_from_chars.cc:1281:10: erro= r: =E2=80=98from_chars_strtod=E2=80=99 was not declared in this scope > 1281 | return from_chars_strtod(first, last, value, fmt); > | ^~~~~~~~~~~~~~~~~ >make[7]: *** [Makefile:587: floating_from_chars.lo] Error 1 /root cause analysis/ The symbol USE_STRTOD_FOR_FROM_CHARS is initially unknown. Since the target system does not use locales, it will not be defined within the scope of floating_to_chars.cc [1]: >#if _GLIBCXX_HAVE_USELOCALE >// FIXME: This should be reimplemented so it doesn't use strtod and newloc= ale. >// That will avoid the need for any memory allocation, meaning that the >// non-conforming errc::not_enough_memory result cannot happen. ># define USE_STRTOD_FOR_FROM_CHARS 1 >#endif This results in code for from_chars_strtod() not being generated (lines 366= to 794) [2]. from_chars() implementation is generated either if USE_LIB_FAST_FLOAT or USE_STRTOD_FOR_FROM_CHARS is enabled [3]. Within this section is code that relies on USE_STRTOD_FOR_FROM_CHARS, but omits to check if the functionalit= y is available [4] >#elif defined(USE_STRTOF128_FOR_FROM_CHARS) >from_chars_result >from_chars(const char* first, const char* last, _Float128& value, > chars_format fmt) noexcept >{ > // fast_float doesn't support IEEE binary128 format, but we can use strt= old. > return from_chars_strtod(first, last, value, fmt); >} >#endif which results in the observed compilation error.=20 /proposed change/ Check if USE_STRTOD_FOR_FROM_CHARS is set before using from_chars_strtod(): --- a/libstdc++-v3/src/c++17/floating_from_chars.cc 2023-04-26 09:09:43.000000000 +0200 +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc 2023-05-19 07:56:56.754330183 +0200 @@ -1264,6 +1264,8 @@ __attribute__((alias ("_ZSt10from_charsPKcS0_RdSt12chars_format"))); #endif +#if defined(USE_STRTOD_FOR_FROM_CHARS) +// otherwise there is no from_chars_strtod #ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT from_chars_result from_chars(const char* first, const char* last, __ieee128& value, @@ -1282,6 +1284,8 @@ } #endif +#endif // USE_STRTOD_FOR_FROM_CHARS + #endif // USE_LIB_FAST_FLOAT || USE_STRTOD_FOR_FROM_CHARS _GLIBCXX_END_NAMESPACE_VERSION [1] https://github.com/gcc-mirror/gcc/blob/7f3df8e65c71e5df01fe7fe7de577bb9ff48= f37b/libstdc%2B%2B-v3/src/c%2B%2B17/floating_from_chars.cc#L53-L58 [2] https://github.com/gcc-mirror/gcc/blob/7f3df8e65c71e5df01fe7fe7de577bb9ff48= f37b/libstdc%2B%2B-v3/src/c%2B%2B17/floating_from_chars.cc#L366-L794 [3] https://github.com/gcc-mirror/gcc/blob/7f3df8e65c71e5df01fe7fe7de577bb9ff48= f37b/libstdc%2B%2B-v3/src/c%2B%2B17/floating_from_chars.cc#L1230-L1342 [4] https://github.com/gcc-mirror/gcc/blob/7f3df8e65c71e5df01fe7fe7de577bb9ff48= f37b/libstdc%2B%2B-v3/src/c%2B%2B17/floating_from_chars.cc#L1317-L1340=