From patchwork Mon Jun 14 12:49:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1491655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G3WVy4X8Hz9sRN for ; Mon, 14 Jun 2021 22:49:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 955AC3855029 for ; Mon, 14 Jun 2021 12:49:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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-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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Found this odd code. It starts fine with: gfc_ref *ref = 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 – which is still '\0' from the first XCNEW: ref->u.ar = *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ünchen Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf 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) {