From patchwork Sat Jul 30 11:37:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp1268048pxt; Sat, 30 Jul 2022 04:37:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uXwti0Ce9O5cPhmKUfNV3fqjjTMjQc+y33uT6U28narH1CbAUb0ZYTRqS/XpWbrk/PK9Wa X-Received: by 2002:a05:6402:280b:b0:43b:5d75:fcfa with SMTP id h11-20020a056402280b00b0043b5d75fcfamr7390236ede.114.1659181076412; Sat, 30 Jul 2022 04:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659181076; cv=none; d=google.com; s=arc-20160816; b=hGmFRWYMCe5X19bQt6+cYI/MsSt9LVSjuwql2gAx5cuMLHSP4rUzHDDkL5CCWYQ1sa /8GA+v5k1cNYOdoSsCzJ9s5azlbY2W3YFld8/xAqI7LZxmVgiOhHTQry7OXvVWmggKBQ qlg/7xXp2y+WIb922tUR+1ueUSKel0Na1HqyEr6nk58LxGnyTQrHSSeKZGsnKrjKZpV1 eZXg0/2UjEqqYz805lzkJbYhfyxoDqmtMaxfR5Y8pRsCJ60bgO0Y57bt1d7Hxl8C608T +Yi+U7rFgaUo0rK/DeCDJtN5G8suRNXRNoYSSo3sNxe0bxQEOTVY44S07L7Fc2m0g658 qljA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=UJBU5YEQqJaMlWXrUSKtASzNYjCteKGUwP2E0vXqdwU=; b=HCgCQou7g+2UUNiPAYoo2Gdz463HKHrjanV88NIafdLPUMfxb9FteSQ0LIC8VY6jCn HqsV+sOx46GiFSGuJ+x4rgFzTrtlL2PFnpayW/0uynS5QPed2dfD9kcetlZzon1Ofxg9 gnk//ZKLMpSO2UtZmS7Ts4ZLJbeyl7ba1yAWG2yiLciiMpURBdEidaR02bFiAsy9Q1kS CEb0DzrpETQTO60Id6V1Mmwis3N+6suY0IY7s748hVOXtcMpeqEQal6FEc1sjaVHYxph u1ITzyS8sdv0CKuN46yKP9bMpT6QuT50hPvSLDe6k/3cUFjDtYh3+wnzna2RH1AQzH5s fwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vFbaqYX0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n14-20020a1709065e0e00b0072f22a0d258si5183092eju.718.2022.07.30.04.37.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 04:37:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vFbaqYX0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 458BA3857034 for ; Sat, 30 Jul 2022 11:37:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 458BA3857034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659181075; bh=UJBU5YEQqJaMlWXrUSKtASzNYjCteKGUwP2E0vXqdwU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vFbaqYX0AYlPCtFJZQY5Gc5IaSJBcHLu/3ORaZkeWnwSzu1lyMYSvPH+lg62WLklr TdPSnbzF8znqnxlul/MdJzVmS2BsYoYnSmEgMuRfmpK4+Sb0ekApGQAqTOtZkRKxUs AXF+vhusZz7u8Bfu2sObizc6qiEvmbj0V2DCfvBU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 CB0BF3858010 for ; Sat, 30 Jul 2022 11:37:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB0BF3858010 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-IWZL9Z9yNOWpVLXyG-J2XA-1; Sat, 30 Jul 2022 07:37:08 -0400 X-MC-Unique: IWZL9Z9yNOWpVLXyG-J2XA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1732F101A54E; Sat, 30 Jul 2022 11:37:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCAD51121314; Sat, 30 Jul 2022 11:37:07 +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 26UBb5Np2075143 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 30 Jul 2022 13:37:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 26UBb5sr2075142; Sat, 30 Jul 2022 13:37:05 +0200 Date: Sat, 30 Jul 2022 13:37:04 +0200 To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] libfortran: Fix up boz_15.f90 on powerpc64le with -mabi=ieeelongdouble [PR106079] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739777456282212956?= X-GMAIL-MSGID: =?utf-8?q?1739777456282212956?= Hi! The boz_15.f90 test FAILs on powerpc64le-linux when -mabi=ieeelongdouble is used (either default through --with-long-double-format=ieee or when used explicitly). The problem is that the read/write transfer routines are called with BT_REAL (or BT_COMPLEX) type and kind 17 which is magic we use to say it is the IEEE quad real(kind=16) rather than the IBM double double real(kind=16). For the floating point input/output we then handle kind 17 specially, but for B/O/Z we just treat the bytes of the floating point value as binary blob and using 17 in that case results in unexpected behavior, for write it means we don't estimate right how many chars we'll need and print ******************** etc. rather than what we should, and even with explicit size we'd print one further byte than intended. For read it would even mean overwriting some unrelated byte after the floating point object. Fixed by using 16 instead of 17 in the read_radix and write_{b,o,z} calls. Bootstrapped/regtested on powerpc64le-linux, ok for trunk / 12.2? 2022-07-30 Jakub Jelinek PR libfortran/106079 * io/transfer.c (formatted_transfer_scalar_read, formatted_transfer_scalar_write): For type BT_REAL with kind 17 change kind to 16 before calling read_radix or write_{b,o,z}. Jakub --- libgfortran/io/transfer.c.jj 2022-01-11 23:49:53.695803219 +0100 +++ libgfortran/io/transfer.c 2022-07-29 16:26:58.414855021 +0200 @@ -1614,6 +1614,10 @@ formatted_transfer_scalar_read (st_param if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif read_radix (dtp, f, p, kind, 2); break; @@ -1626,6 +1630,10 @@ formatted_transfer_scalar_read (st_param if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif read_radix (dtp, f, p, kind, 8); break; @@ -1638,6 +1646,10 @@ formatted_transfer_scalar_read (st_param if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif read_radix (dtp, f, p, kind, 16); break; @@ -2085,6 +2097,10 @@ formatted_transfer_scalar_write (st_para if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif write_b (dtp, f, p, kind); break; @@ -2097,6 +2113,10 @@ formatted_transfer_scalar_write (st_para if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif write_o (dtp, f, p, kind); break; @@ -2109,6 +2129,10 @@ formatted_transfer_scalar_write (st_para if (!(compile_options.allow_std & GFC_STD_F2008) && require_type (dtp, BT_INTEGER, type, f)) return; +#ifdef HAVE_GFC_REAL_17 + if (type == BT_REAL && kind == 17) + kind = 16; +#endif write_z (dtp, f, p, kind); break;