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.133.124]) by sourceware.org (Postfix) with ESMTPS id 2F46D385B529 for ; Tue, 7 May 2024 13:50:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F46D385B529 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F46D385B529 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715089824; cv=none; b=CvJaSLnBIrvDpzmF0t4Feamb6hXFDwx+hX7DpwPo7OCJlsK1TTSwokAMSqYgi9kUxXLbqYAvIQblxlMjUywynsT9VayqrNlB4zp2qCm6ek/k7ZDOB5gtGPpbzz0BKvItKlwo7E8tzBSsZrVd1CyOtfOCVe8h8ruZUdfCuI3qgd8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715089824; c=relaxed/simple; bh=RUYvIx18e34fC1WloQMwyjA2utKNneE99v+BpN/hI20=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NBiCameX/KoAzaWvwiZctG41tzCrpNSQZZfp8/1dFWotjonA0ZUYg4xR7awY2vIvI2v+2vtfM+eliN1LTu4+//IpZbBRrQejt8IrEbCAm+KZRM1/JVUbjkrNOxMm5ISpqnrf78VD9iafit0Ox/AS85XKnn8WhdQgRCFpSuTYKOc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715089822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Fh85eEO0B76I9SK5I9j+U98Ua9wDPHJAwSZ8mWwlUO0=; b=ha8XdJF7tKgHpsU13raNqSFAQG2JqQwtT/Dh9U5Hc09IvrkxzRDU72ARS6hwjDb+Jgsl9X xMyzZIFDsEmpa+aAhFR7/T4+5q7vlWyJVt+mcbjdDTqwPyI1YTwwqJ712r1TDknIIG44em 9xi1b1u70mLbGQCLK7Aur++QNNr314Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-16Nam6ZzPx-ZiwtDgPusgA-1; Tue, 07 May 2024 09:50:21 -0400 X-MC-Unique: 16Nam6ZzPx-ZiwtDgPusgA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13FE48015D7; Tue, 7 May 2024 13:50:21 +0000 (UTC) Received: from localhost (unknown [10.42.28.238]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4349492CAB; Tue, 7 May 2024 13:50:20 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH][risc-v] libstdc++: Preserve signbit of nan when converting float to double [PR113578] Date: Tue, 7 May 2024 14:49:33 +0100 Message-ID: <20240507135019.3821031-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: Do we want this change for RISC-V, to fix PR113578? I haven't tested it on RISC-V, only on x86_64-linux (where it doesn't do anything). -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/113578 * include/std/ostream (operator<<(basic_ostream&, float)): Restore signbit after converting to double. --- libstdc++-v3/include/std/ostream | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index 8a21758d0a3..d492168ca0e 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -233,7 +233,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 117. basic_ostream uses nonexistent num_put member functions. +#ifdef __riscv + return _M_insert(__builtin_copysign((double)__f, + (double)-__builtin_signbit(__f)); +#else return _M_insert(static_cast(__f)); +#endif } __ostream_type& -- 2.44.0