From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 604F33858C62; Thu, 8 Jun 2023 09:12:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 604F33858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2566ed9328eso279813a91.2; Thu, 08 Jun 2023 02:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686215523; x=1688807523; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A14XdwZYz90BGcU4QcKrrPMTh8+wmL76T26vdsWVjY4=; b=pF06QgMTIp3fpclCfpse5RQFP9XTYF1PQH9/cHv3YJStQb3sbCFw43czQYf0AilZ3h k7CWolugSYkTr4Ldk8FZVGoWHQAhElmTaE6d+9Na4Y4cG+sAJsLzvIULsnGg80yVmVpV 6yCE+0g8Ndjqtt1BdmBDOExngVoF2jKoLfmB2eRbT75mq2ohozSOq+EjyWxN1Uyx/NhP J2WQvpfhKmFlw+kGj8MAmaW2vQ7AKxuQAfmYsFgtyX2R2CYZdTIyo6TsPYQHqeebLoGO ThrbLH91lF8SPyyxvLTstoJOThRL+uyVWlt1egKViESPPKPxnQDSuFX95b7NiW1oD1Er Z4DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686215523; x=1688807523; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A14XdwZYz90BGcU4QcKrrPMTh8+wmL76T26vdsWVjY4=; b=ZXJlGnmQoDQQ1omrgVNKsm3P953qnL55c4r27HK8Eln+1OFbN+bl/FSar85httqaxj KkwqOLWSUhuMC/jiyahqpZBSlT9QHqOdbKSQ0RlP0t5VtHRVnn4SJjRypR7g9Inb4zm5 1zNrh04EeWXg2wcIKYLUBWh8MsTqA/XBtGVY4xzg2fQy1D4YoYOSiwFGTg+g5XLgd8dK WV0fo4NBfhR5uNPCxg0sfQGtW5N6pXlbIS+704Bbu+xcxxKXQjIdaUbWp3ocGmKdxcoR L+XbEpOu4Mvg7lcUYIMRpWouS94JOltwWv6xF/TluEGkeWKnqmkj115OJ0wNgTi2IqJg BHWw== X-Gm-Message-State: AC+VfDwfMml5CsaItzyBMiZqnH+dS2zlD7IHzHLtL8mCAe6x5fZkMLpu 8x3hjysi9nZ+eJY9HdRXJFIIyCz5I5Q+FL6pv7o= X-Google-Smtp-Source: ACHHUZ7A2eIt37SKKV6VkHS4waMUeYYcIxuGcwfNNfTZP9uxauvlhiAYsWRwEx7kN6Ps91n+Y0euDrFq67VQWk3VD2Q= X-Received: by 2002:a17:90a:d595:b0:255:614a:7fae with SMTP id v21-20020a17090ad59500b00255614a7faemr6944232pju.20.1686215523166; Thu, 08 Jun 2023 02:12:03 -0700 (PDT) MIME-Version: 1.0 References: <18005e9d-e0af-8d94-d490-80fc3a5f3840@orange.fr> In-Reply-To: From: Paul Richard Thomas Date: Thu, 8 Jun 2023 10:11:51 +0100 Message-ID: Subject: Re: [Patch, fortran] PR87477 - (associate) - [meta-bug] [F03] issues concerning the ASSOCIATE statement To: Harald Anlauf Cc: Mikael Morin , "fortran@gcc.gnu.org" , gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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: Thanks Gents! The solution is to gfc_free_expr (p) if the replacement is not made. I am regtesting a patch for PR107900. I'll include the fix for the memory leak in the patch for that. Cheers Paul On Thu, 8 Jun 2023 at 09:30, Harald Anlauf wrote: > > On 6/8/23 09:46, Mikael Morin wrote: > > Le 08/06/2023 =C3=A0 07:57, Paul Richard Thomas via Fortran a =C3=A9cri= t : > >> Hi Harald, > >> > >> In answer to your question: > >> void > >> gfc_replace_expr (gfc_expr *dest, gfc_expr *src) > >> { > >> free_expr0 (dest); > >> *dest =3D *src; > >> free (src); > >> } > >> So it does indeed do the job. > >> > > Sure, but his comment was about the case gfc_replace_expr is *not* > > executed. > > Right. The following legal code exhibits the leak, pointing > to the gfc_copy_expr: > > subroutine paul (n) > integer :: n > character(n) :: c > end > > >> I should perhaps have remarked that, following the divide error, > >> gfc_simplify_expr was returning a mutilated version of the expression > >> and this was somehow connected with successfully simplifying the > >> parentheses. Copying and replacing on no errors deals with the > >> problem. > >> > > Is the expression mutilated enough that it can't be safely freed? > > > > > > > --=20 "If you can't explain it simply, you don't understand it well enough" - Albert Einstein