From patchwork Sat Feb 25 18:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 61535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1605888wrd; Sat, 25 Feb 2023 10:18:27 -0800 (PST) X-Google-Smtp-Source: AK7set/TEoX/4kg4DuFn1/8ypE4ZEjlx8DgDWZSVk/oXvL0KG/XjJYAaiCefQbQhrPOA7xF0B6yE X-Received: by 2002:a17:906:99d3:b0:8ef:fd8:9d04 with SMTP id s19-20020a17090699d300b008ef0fd89d04mr11146214ejn.27.1677349107349; Sat, 25 Feb 2023 10:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677349107; cv=none; d=google.com; s=arc-20160816; b=bGqBAEgbFXQgqwgZWTsAOkKkx5Y+RSpmVxykzPyT+sWF2Tpsv2eEiedgZ7qWMwqtpf MH9t9bzPlypa3v0BwjTdYC5cQrdZNZMVVQFYcfxQW9xtcmKX76DH5w3nToOfeifYkRXP sWxoT5Oyn5F6RSJNwlhH7VHpGN0WO2OhcXTUeOMPAXlitD/oKSd+Y6B9kVDYiuleqIcI DjvSbCyizIVkYWZNp9PRVKnckfF2caQOLkMeMLL4nn2T78p54bf2y9Jv2NqAViSL8QMu 5D34UKnbJN4M74Z/NB5p5J7/kdcSCL46l2R+eZJ2AtzYMavdu5+/2HzFYWDRD3addM8Y pzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=m9Egrz7IT3YVLsEg6OMHOtk2ZIXNkM2DbEh0QqwK/+c=; b=au2DSOeGHYojcaoScJEwjWqCTzzZ7mwYLSbCYrQrEmzonHUHJyxF2dR0c6tYNjvZDc bO7JhRBf6FYFxxC25tu1VX9rK8iWB/WkqfSGdOoPwrYnRhBa6TNuYMrvI1DFSS7xHa6M a9Ssr5pEu23XLTSki54UfBF1Gi/gXg7oaVnydUqQE3s0Lua3FUigxSkTZexjubiCFrku y43A+N/w/l1JRjqrlvQLmLULopdu/grjY//TQcp6Z21kqhVhKuEA4PbbLW/Rofs/jbRg 3ciAb47czrCY9QZiG6pmTS91maJ/ETCJdm828/CXdnUpvLWvXp0fiXIvO69F9jR9/+TR R1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GD9ivV4C; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v20-20020aa7d654000000b004acb6009aa3si2996172edr.617.2023.02.25.10.18.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Feb 2023 10:18:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GD9ivV4C; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29BC638515D7 for ; Sat, 25 Feb 2023 18:18:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29BC638515D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677349106; bh=m9Egrz7IT3YVLsEg6OMHOtk2ZIXNkM2DbEh0QqwK/+c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GD9ivV4Cs2sDCenenv7SRikN/g2ECLD5aVwgE60wRV/OBresLt287OdEI9HgzfaBi SWoXmSB5KanfkIqzNBe5Krggfh2hT6RqK24rS81ufOs2gg9kNB+oADg1AEBSx63ymO P3X8OGTLbdOV/PCPC5nNnGWnH3coYrgxL31xuAWU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by sourceware.org (Postfix) with ESMTPS id 392E5385841A; Sat, 25 Feb 2023 18:17:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 392E5385841A X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.147.80] ([79.232.147.80]) by web-mail.gmx.net (3c-app-gmx-bap72.server.lan [172.19.172.172]) (via HTTP); Sat, 25 Feb 2023 19:17:23 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: fix memory leak with real to integer conversion warning Date: Sat, 25 Feb 2023 19:17:23 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:ywyhvl1F+sYq9hr+nt1usAw8q7SrtHNc0WuWqo7BFGwyx3/n2epG6YNEkKhiKjQZN0N5u Q2qzUmelYEWE2uMGV+TyeYTjyYMEa+v5mufFjcEMUrKsyvYoSjKDdOK/dsSQgBa3qu6c6kFcAj+c WSs/yZJh1Ob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_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758828017891789046?= X-GMAIL-MSGID: =?utf-8?q?1758828017891789046?= Dear all, while checking f951 for memory leaks on testcases that appeared relevant during work on pr108924, I found that the conversion warning triggered by do_subscript_6.f90 uses a code path that forgot to mpfr_clear a used variable. The attached obvious patch fixes this - verified by valgrind. Pushed to mainline as r13-6344-g03c60e525bea13 . Thanks, Harald From 03c60e525bea13c15edd2f64cd582f168fe80bfb Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 25 Feb 2023 19:05:38 +0100 Subject: [PATCH] Fortran: fix memory leak with real to integer conversion warning gcc/fortran/ChangeLog: * arith.cc (gfc_real2int): Clear mpfr variable after use. --- gcc/fortran/arith.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index d0d1c0b03d2..37aeaf1b186 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -2257,6 +2257,7 @@ gfc_real2int (gfc_expr *src, int kind) gfc_typename (&result->ts), &src->where); did_warn = true; } + mpfr_clear (f); } if (!did_warn && warn_conversion_extra) { -- 2.35.3