From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id 736BF3858C50; Wed, 8 May 2024 21:06:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 736BF3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 736BF3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715202406; cv=none; b=XFzqkgKq7NLylbreaweD5BnjA7yBZxitMxcHTSJiT5b8FygeNvjm9czmwLJo4blUSRNYf0XTiwDNVse5U3iF1zNF0yjogFCv8wkeLnkDo06N/Pv2JjCcizJ95SlHre4wAGy83lyJjyQJQWU7n1etW2xUAW1yYjfY6mLjxT7zwJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715202406; c=relaxed/simple; bh=XljHn1TiqWb4rRsSJFuK9RYCdvfgHZJOVF2B54sh2VQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=NpTkeOfYsRKs5cpS30wFL7p1OWSuOSk+xrwTup9/iJrWZbN/ypdwc/TnkxLgETKnaoGQNdUMs8zqBN7w5A7WziRUWy5HTmEFDI1Z6XPn66x5ChlJORl4qYBVTz9wdL44cGq5wq8yYt/rK/zbTa5krM1q4q6AMChscmC3MCZJd+0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1715202402; x=1715807202; i=anlauf@gmx.de; bh=k0i5uhO2MmViYmYfPw4aiF5w+KFslGiqqKQuzrtLNGs=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=LadjzFxXUFZNT4iz/y1Xsl515mrFZYpvDeGpQTcoWgf3CS0WmE825B0IZbXvE7V6 itc28ezNzVz7b7l4+jMEehw5swxF+ThYnkn6gzvq8s/7XRuvj/hbuTH3r5YfrRHCh REzSKHDwB8WFAZLF5+WZTUJJzSGNa4si9AeZpkE1N7bNjrMmttsM5f4bz4OACY3b1 SNMQNbIVC7bF5iVafPpUotHr8ybn7vgatllezjM3wm9vOOSun/OzeY9m//zR0ZdxU UhavFZITqFExNIEBCBkZjF9X22SMngrJzazcMVaDU2rTpebOVnMdsWkqefWhfiW4R lfSYFRaZOD1cG7FGuA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.251.5.164]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MYeQr-1s8Iqn1WGR-00Yy0j; Wed, 08 May 2024 23:06:42 +0200 Message-ID: Date: Wed, 8 May 2024 23:06:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Patch, fortran] PR84006 [11/12/13/14/15 Regression] ICE in storage_size() with CLASS entity To: Paul Richard Thomas , "fortran@gcc.gnu.org" , gcc-patches Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: Content-Language: en-US From: Harald Anlauf In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Q7QSpx3zbz2++ROiKQBIkEVyMo/UMbU7RWAA4sIGmfk+d5WCdHG vTrmqWyWRIpyVAwU4C1jPEFlsUwk5oorU14VOJhuPKfpAbOcEXOmdoZVBSTcjE7RnEdFs4+ Ss6gyiOFoBJW3cblPf+kPNWnNuY/4B3VniuVndUpY4bVeM0F5Xr4XG8W0DK31s+YuFgyxFZ 34uWZA5wzGbXAPnLZfejA== UI-Outbound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autolearn=no 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 Paul, this looks mostly good, but the new testcase transfer_class_4.f90 does exhibit a problem with your patch. Run it with valgrind, or with -fcheck=3Dbounds, or with -fsanitize=3Daddress, or add the following around the final transfer: print *, storage_size (star_a), storage_size (chr_a), size (chr_a), len (chr_a) chr_a =3D transfer (star_a, chr_a) print *, storage_size (star_a), storage_size (chr_a), size (chr_a), len (chr_a) print *, ">", chr_a, "<" This prints for me: 40 40 2 5$ 40 40 4 5$ >abcdefghij^@^@^@^@^@^@^@^@^@^@<$ So since the physical representation of chr_a is sufficient to hold star_a (F2023:16.9.212), no reallocation with a wrong calculated size should happen. (Intel and NAG get this right.) Can you check again? Thanks, Harald Am 08.05.24 um 17:01 schrieb Paul Richard Thomas: > This fix is straightforward and described by the ChangeLog. Jose Rui > Faustino de Sousa posted the same fix for the ICE on the fortran list > slightly more than three years ago. Thinking that he had commit rights, = I > deferred but, regrettably, the patch was never applied. The attached pat= ch > also fixes storage_size and transfer for unlimited polymorphic arguments > with character payloads. > > OK for mainline and backporting after a reasonable interval? > > Paul > > Fortran: Unlimited polymorphic intrinsic function arguments [PR84006] > > 2024-05-08 Paul Thomas > > gcc/fortran > PR fortran/84006 > PR fortran/100027 > PR fortran/98534 > * trans-expr.cc (gfc_resize_class_size_with_len): Use the fold > even if a block is not available in which to fix the result. > (trans_class_assignment): Enable correct assignment of > character expressions to unlimited polymorphic variables using > lhs _len field and rse string_length. > * trans-intrinsic.cc (gfc_conv_intrinsic_storage_size): Extract > the class expression so that the unlimited polymorphic class > expression can be used in gfc_resize_class_size_with_len to > obtain the storage size for character payloads. Guard the use > of GFC_DECL_SAVED_DESCRIPTOR by testing for DECL_LANG_SPECIFIC > to prevent the ICE. Also, invert the order to use the class > expression extracted from the argument. > (gfc_conv_intrinsic_transfer): In same way as 'storage_size', > use the _len field to obtaining the correct length for arg 1. > > gcc/testsuite/ > PR fortran/84006 > PR fortran/100027 > * gfortran.dg/storage_size_7.f90: New test. > > PR fortran/98534 > * gfortran.dg/transfer_class_4.f90: New test. > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 6AE033858C35 for ; Wed, 8 May 2024 21:06:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AE033858C35 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6AE033858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=116.202.254.214 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715202420; cv=none; b=e/PAt7pInqc/OeWxpWGs4yE/YR8keJxpjuTpzdn3oaZlr1WzN5hcN2F58fAdDYDDHoc3QhHAZmFXzz0P71oyXC23YNkNcDWGXII/q2uKMrMlTyQkdZvcEfXGE+p0qezpA7u+dxMAiARWny2CXZ7kgpuNFM7SHGKdNw2xcH96c8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715202420; c=relaxed/simple; bh=loOS8n5IZl7hvp61kslE946vmoErOFyj1tzA7MJCYA4=; h=To:From:Subject:Date:Message-ID:Mime-Version; b=TMWl220HEArK0PwxLPXsFp3qZ+l0EG6qRmLYiwR9atwvHMBKxoz/cz6qOCbuE598dHcma9mUot/PrFW9yZl9nJ93cxxfO9ACpFRym5imQ4ypF4OY5PoKXr7Elbe8Q27xz28nXrGCl0pYDt7qVnac8nicP9J56nwNJv669MXuLs0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1s4oV1-0003yt-I0 for gcc-patches@gcc.gnu.org; Wed, 08 May 2024 23:06:53 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [Patch, fortran] PR84006 [11/12/13/14/15 Regression] ICE in storage_size() with CLASS entity Date: Wed, 8 May 2024 23:06:41 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,LOTS_OF_MONEY,MONEY_NOHTML,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20240508210641.qL12JoIXMOUI_n-g7GqbA4QtgmfZJf8BuYIh1x273QA@z> Hi Paul, this looks mostly good, but the new testcase transfer_class_4.f90 does exhibit a problem with your patch. Run it with valgrind, or with -fcheck=bounds, or with -fsanitize=address, or add the following around the final transfer: print *, storage_size (star_a), storage_size (chr_a), size (chr_a), len (chr_a) chr_a = transfer (star_a, chr_a) print *, storage_size (star_a), storage_size (chr_a), size (chr_a), len (chr_a) print *, ">", chr_a, "<" This prints for me: 40 40 2 5$ 40 40 4 5$ >abcdefghij^@^@^@^@^@^@^@^@^@^@<$ So since the physical representation of chr_a is sufficient to hold star_a (F2023:16.9.212), no reallocation with a wrong calculated size should happen. (Intel and NAG get this right.) Can you check again? Thanks, Harald Am 08.05.24 um 17:01 schrieb Paul Richard Thomas: > This fix is straightforward and described by the ChangeLog. Jose Rui > Faustino de Sousa posted the same fix for the ICE on the fortran list > slightly more than three years ago. Thinking that he had commit rights, I > deferred but, regrettably, the patch was never applied. The attached patch > also fixes storage_size and transfer for unlimited polymorphic arguments > with character payloads. > > OK for mainline and backporting after a reasonable interval? > > Paul > > Fortran: Unlimited polymorphic intrinsic function arguments [PR84006] > > 2024-05-08 Paul Thomas > > gcc/fortran > PR fortran/84006 > PR fortran/100027 > PR fortran/98534 > * trans-expr.cc (gfc_resize_class_size_with_len): Use the fold > even if a block is not available in which to fix the result. > (trans_class_assignment): Enable correct assignment of > character expressions to unlimited polymorphic variables using > lhs _len field and rse string_length. > * trans-intrinsic.cc (gfc_conv_intrinsic_storage_size): Extract > the class expression so that the unlimited polymorphic class > expression can be used in gfc_resize_class_size_with_len to > obtain the storage size for character payloads. Guard the use > of GFC_DECL_SAVED_DESCRIPTOR by testing for DECL_LANG_SPECIFIC > to prevent the ICE. Also, invert the order to use the class > expression extracted from the argument. > (gfc_conv_intrinsic_transfer): In same way as 'storage_size', > use the _len field to obtaining the correct length for arg 1. > > gcc/testsuite/ > PR fortran/84006 > PR fortran/100027 > * gfortran.dg/storage_size_7.f90: New test. > > PR fortran/98534 > * gfortran.dg/transfer_class_4.f90: New test. >