From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id B80233855029; Mon, 14 Jun 2021 12:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B80233855029 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: EFqObukAwvWZH1L4QWxC7SKhtziI+Qbxk3+Uebu+JCDYNjj0nXIPSLKXGmcnnV20GM4IDk8XZD qN9toUYB5RzyJaIZOKoW7uz4iGseb8eqpagsyeeLRnrZ6NQz3SXoHvOcFdPVhQvLRkihjJ8y1z 1XQK+LyCG+kE10h0aDZhyjhrkG8ZegmpMZOVwR6B7AYE1rRRF0D1BnmkKREkVF/gh03y53Iraw UsRrxdI8Z8nWiscwAlmtbr7fFV6T3IhP2Ch34ALEMczqWB3E7AQ2KIcELeqirBqdCvX/FnoUeP mXI= X-IronPort-AV: E=Sophos;i="5.83,273,1616486400"; d="diff'?scan'208";a="62351761" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 14 Jun 2021 04:49:06 -0800 IronPort-SDR: nzax6vaxsMEdhzG3Sp1m82VqNt46NEKIw4yBguTvscDwRvucKAsEdH2rL/yTtMAC58jz2nZKMy 0LCzq+GxTz0YmU12m7zWvBwbOmHc3b7lkWhGnETou8WneoP1yn2ExoAb3GAcGzDJiQ77vFQR27 QpZZ4baEyZnvRA+lvBOiqMCXdQBB1bTFdR/3SmMpilciGI2pxlbcb88dDQP9Lhf5QHMcbL9Bob ag6r8pCxjsaEf9eDqUyDJb+CyPRB2HKOMYmap7wGaa4DkON2UKQ0owB0hXf7bS6pf6b0TsaN1a ktA= To: gcc-patches , fortran From: Tobias Burnus Subject: [committed] Fortran: resolve.c - remove '*XCNEW' based nullifying Message-ID: <06938d43-cefc-61cb-aab5-c96c4a626886@codesourcery.com> Date: Mon, 14 Jun 2021 14:49:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------852578FD8E9BCE5D72BB42E5" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Mon, 14 Jun 2021 12:49:09 -0000 --------------852578FD8E9BCE5D72BB42E5 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Found this odd code. It starts fine with: gfc_ref *ref =3D gfc_get_ref (); this uses XCNEW to return nullified memory. We then operate on ref->u.ar where 'ar' is a struct which is in a 'u'nion which is in gfc_ref. Hence, 'ref->u.ar' is not a pointer. Hence, the following is a wasteful way to memset '\0' the struct =E2=80=93 which is still '\0' from the first XCNEW: ref->u.ar =3D *gfc_get_array_ref() Note the '*' before the XCNEW calling macro gfc_get_array_ref! Committed as obvious. Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf --------------852578FD8E9BCE5D72BB42E5 Content-Type: text/x-patch; charset="UTF-8"; name="committed.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="committed.diff" commit a893b26f7311fe65b604f12a8fa5d5d64f5454e2 Author: Tobias Burnus Date: Mon Jun 14 14:36:20 2021 +0200 Fortran: resolve.c - remove '*XCNEW' based nullifying gcc/fortran/ChangeLog: * resolve.c (resolve_variable): Remove *XCNEW used to nullify nullified memory. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a37ad665645..45c3ad387ac 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5709,7 +5709,6 @@ resolve_variable (gfc_expr *e) part_ref. */ gfc_ref *ref = gfc_get_ref (); ref->type = REF_ARRAY; - ref->u.ar = *gfc_get_array_ref(); ref->u.ar.type = AR_FULL; if (sym->as) { --------------852578FD8E9BCE5D72BB42E5--