From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 86D2C3858C50; Mon, 6 Nov 2023 18:12:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86D2C3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 86D2C3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699294325; cv=none; b=boOXlt98ugvrKsjmWynG4TX3Fh6Gmkl1r6DvpXl1o0uVCIuz49yiyL9L3ZAZb6MybByuB5M1c9p6JSDHgpZnAvR3T4+766YekjkiKOyk4WjbC6cLBWjucpccUZFcAj7k0WQpJPlhhygjAz3YM0l62EYrVEUO3Di2rv2C+3dTfzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699294325; c=relaxed/simple; bh=+hjwMSlgu/T7Z7uWIifElxjLgOY8qv50erIjH+v9tnw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XsF8+j2zBjNn7Rvyz1DAs547NirkBikQ94ATkj8NQzpmHPHwioxpPy2EHnqy7sRkM/zeagmMlOg5D/yJ94d34fRFdEdOdfENvcRyt0/MgLmHKoW67d1Rot9y8eFxdPZhRWllAYyZ6b2m0Qa5w9HQ70243Gj/Uunt90qCQmGnhMY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699294322; x=1699899122; i=anlauf@gmx.de; bh=+hjwMSlgu/T7Z7uWIifElxjLgOY8qv50erIjH+v9tnw=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=HiaF4Pv+YpopEkPGgxb77El2LCoQAmU81HifH7vVYtKV6qrQD1UB2CkX+K/gHRdx AopYEPPbH4QFgl4zGMcqVcCPGQ5Z61c2ik4/Lu7ge5z9bstuMjAtu5BsXGjmL+Uyg nYbvnE0PrENmqo06rnBiskfo1cx4ecRda6zIvAhR2AHOxYcsTRjWF/FAZf2TJm3YL THi7ck0BH8QbqxbXz4eFERRtuJE0hOJKck8opMDnVkXeqOAyIWobJMARxn9JTGqMU mbL5uz5ESPcx+AMIPSYXjBaGHLC4RfduJ2qTzTJEHLkOvHhSjJJCWYlVB4aukpg3E gXIbVBI5HDM9/KvVng== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.29] ([79.232.146.236]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MqaxU-1rmaAL3jjk-00ma5Z; Mon, 06 Nov 2023 19:12:01 +0100 Message-ID: <8e65205b-fbe9-40fb-ba72-a77ab87ab688@gmx.de> Date: Mon, 6 Nov 2023 19:12:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] libgfortran: Remove early return if extent is zero [PR112371] To: Mikael Morin , gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Newsgroups: gmane.comp.gcc.patches,gmane.comp.gcc.fortran References: <20231106114325.828968-1-mikael@gcc.gnu.org> <20231106114325.828968-2-mikael@gcc.gnu.org> Content-Language: en-US From: Harald Anlauf In-Reply-To: <20231106114325.828968-2-mikael@gcc.gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:siHu5jvXy//ikmRotVz01EwtfhsnYDRnPnTLWEE3AWzXjxeZ9EI uoeaupmc6ninHlbdomZXNbjKUrT/a1pMhXkM1GQyMY7jREWa1rDtiXGKJE+fjP1wyjxRf1l jAB6KA1QnzO8eJEid/WKEOJIdJ7gD5PGOGP1HXJZpgfmvwUWq5AexWV7KY9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I= X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Mikael, Am 06.11.23 um 12:43 schrieb Mikael Morin: > Remove the early return present in function templates for transformation= al > functions doing a (masked) reduction of an array along a dimension. > This early return, which triggered if the extent in the reduction dimens= ion > was zero, was wrong because even if the reduction operation degenerates = to > a constant value in that case, one has to loop anyway along the other > dimensions to initialize every element of the resulting array with that > constant value. > > The offending piece of code was present in several places, and this remo= ves > them all. Namely, the impacted m4 files are ifunction.m4 for regular > functions and types, ifunction-s.m4 for character minloc and maxloc, and > ifunction-s2.m4 for character minval and maxval. I wonder if the correct fix would be to replace (instead of deleting) > diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 > index c64217ec5db..480649cf691 100644 > --- a/libgfortran/m4/ifunction.m4 > +++ b/libgfortran/m4/ifunction.m4 > @@ -232,8 +232,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const re= strict retarray, > } > > len =3D GFC_DESCRIPTOR_EXTENT(array,dim); > - if (len <=3D 0) > - return; > > mbase =3D mask->base_addr; > by the following: if (len < 0) len =3D 0; See ifunction.m4, lines 56ff, which check if the result of len =3D GFC_DESCRIPTOR_EXTENT(array,dim); is negative. I haven't tried to create a testcase, though. Similarly for the other templates. Thanks, Harald