From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 543F23854545 for ; Wed, 23 Nov 2022 08:55:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 543F23854545 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669193709; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=OzD3fG5UL8sVxy3By/qNnZjN3mxnD0WO9tk+2D7dtuk=; b=QexAm4JapLwMsGeJN+iEb5pf5R/a7/bdS1pKi0tsLvu2rbxNaSpS89osAx7Z8bsa5JiSwP f4I/scogCoBTGgSkJZWNz0QuoM0vSD7X0AwKWcOI+QYP4+56WoRpdfblRntJ0bEHH43BfZ TaDIvzM2hlx0jbYn28ROzIobvexaVCg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-M_gYY0XAOfaXPDIIcyVjQg-1; Wed, 23 Nov 2022 03:55:06 -0500 X-MC-Unique: M_gYY0XAOfaXPDIIcyVjQg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2045F2932486; Wed, 23 Nov 2022 08:55:06 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3DBC1415114; Wed, 23 Nov 2022 08:55:05 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2AN8t1RL2527547 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 09:55:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AN8t1ia2527546; Wed, 23 Nov 2022 09:55:01 +0100 Date: Wed, 23 Nov 2022 09:55:00 +0100 From: Jakub Jelinek To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix libstdc++ build on some targets [PR107811] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! fast_float library relies on size_t being 32-bit or larger and float/double being IEEE single/double. Otherwise we only use strtod/strtof. In 3 spots I've used fast_float namespace stuff unconditionally in one function, which breaks the build if fast_float is disabled. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-11-23 Jakub Jelinek PR libstdc++/107811 * src/c++17/floating_from_chars.cc (__floating_from_chars_hex): Guard fast_float uses with #if USE_LIB_FAST_FLOAT and for mantissa_bits and exponent_bits provide a fallback. --- libstdc++-v3/src/c++17/floating_from_chars.cc.jj 2022-11-08 09:54:37.533397224 +0100 +++ libstdc++-v3/src/c++17/floating_from_chars.cc 2022-11-22 14:03:10.365474110 +0100 @@ -783,11 +783,16 @@ namespace using uint_t = conditional_t, uint32_t, conditional_t, uint64_t, uint16_t>>; +#if USE_LIB_FAST_FLOAT constexpr int mantissa_bits = fast_float::binary_format::mantissa_explicit_bits(); constexpr int exponent_bits = is_same_v ? 11 : is_same_v ? 5 : 8; +#else + constexpr int mantissa_bits = is_same_v ? 23 : 52; + constexpr int exponent_bits = is_same_v ? 8 : 11; +#endif constexpr int exponent_bias = (1 << (exponent_bits - 1)) - 1; __glibcxx_requires_valid_range(first, last); @@ -945,8 +950,11 @@ namespace else if (mantissa_idx >= -4) { if constexpr (is_same_v +#if USE_LIB_FAST_FLOAT || is_same_v) + fast_float::floating_type_bfloat16_t> +#endif + ) { __glibcxx_assert(mantissa_idx == -1); mantissa |= hexit >> 1; @@ -1130,6 +1138,7 @@ namespace } if constexpr (is_same_v || is_same_v) memcpy(&value, &result, sizeof(result)); +#if USE_LIB_FAST_FLOAT else if constexpr (is_same_v) { uint32_t res = uint32_t{result} << 16; @@ -1156,6 +1165,7 @@ namespace | ((uint32_t{result} & 0x8000) << 16)); memcpy(value.x, &res, sizeof(res)); } +#endif return {first, errc{}}; } Jakub