From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id D480E3858D33 for ; Wed, 8 Mar 2023 16:29:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D480E3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.98,244,1673942400"; d="scan'208";a="103591131" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 08 Mar 2023 08:29:39 -0800 IronPort-SDR: iEwb1CoAScrkEaWetOqtaB9vfRNgZUvqN3cRd0Bp8izc/Ey623+HYUFq0EcnJ3sgMsBRsVvjpw 7SbQUllFILbnewv8NrRg6suppgP0YKlZ2rXNorghB2ZeZExFjRinTLVnRd/DTFH8Aw93GPv1Dj 83KcecCKoc5NhbHQLHHYyHoO9iSD+rwtP5vzWCppBzriz25qvAcp27j7/n9vlwee5CNSN6Uvr+ kcmStScV6zd+qJJnm33NJ3oEGjXfcMT+pHpnploTGB8hGNKf9Zw/MeefpAC2enooF5vwTwWTE4 N80= Message-ID: Date: Wed, 8 Mar 2023 17:29:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [Patch, fortran] PR37336 finalization Content-Language: en-US To: , Paul Richard Thomas CC: Thomas Koenig , "fortran@gcc.gnu.org" References: <582085ac-0d07-a516-732d-e82e0a4e01c9@netcologne.de> From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 08.03.23 16:12, Steve Kargl via Fortran wrote: > For one of my codes, I see > % foreach i (*.o) > foreach? nm $i | grep final > foreach? end > 0000000000000280 T __beamsm_MOD___final_beamsm_Table_t > 0000000000000580 T __bsam_MOD___final_bsam_Bsa_info_t > 00000000000001e0 T __bsam_MOD___final_bsam_Bsa_t > 00000000000000a0 T __ffn_data_MOD___final_ffn_data_Fe_t > > I do not explicitly use finalization nor do I have > subprograms named __final_*. To me, this re-inforces > Richard's point about not breaking existing code. I think there are two places where finalization is touched: (a) when declaring a type, finalization procedures might get generated.(*) =E2=80=94= And, (b) invoking finalization procedures. (a) happens if you have you explicitly add finalization functions =E2=80=93= or (I believe) when you have allocatable components as GCC may then need to free them. I think (b) only happens if you either have polymorphism (as then you don't know whether the polymorphic function uses finalization) =E2=80=93 or= when you invoke explicitly finalization. I believe you run into (a) =E2=80=93 the finalization generation. My understanding is that Paul's patch is mostly about (b) and for sure not for the default-generated procedures. But of course, any code one touches for one purpose can still have side effects, affecting seemingly unrelated code. Tobias PS: I think we should change at some point when the virtual tables and their default procs (init, copy, finalize) generated. Namely, instead of generating them for all types =E2=80=93 even if not used= =E2=80=93 it makes sense to generate them only when a type is used in CLASS(t). This will lead to the generation in multiple translation units, but weak symbols come to a rescue =E2=80=93 and for a MODULE, it can be stored in th= e .mod file that the vtable + funcs has been generated. That way, way fewer vtables are generated, saving a lot of space and reducing compile time! ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955