From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cc-smtpout2.netcologne.de (cc-smtpout2.netcologne.de [89.1.8.212]) by sourceware.org (Postfix) with ESMTPS id 51017385B80B for ; Thu, 17 Feb 2022 21:23:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 51017385B80B Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id C787F127BC; Thu, 17 Feb 2022 22:23:37 +0100 (CET) Received: from [IPV6:2001:4dd6:19cd:0:7285:c2ff:fe6c:992d] (2001-4dd6-19cd-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd6:19cd:0:7285:c2ff:fe6c:992d]) (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 cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id 38C5F11F51; Thu, 17 Feb 2022 22:23:26 +0100 (CET) Message-ID: <061aee5b-c27c-3a9f-419d-9893c2d744c4@netcologne.de> Date: Thu, 17 Feb 2022 22:23:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [Patch, fortran] PR37336 (Finalization) - [F03] Finish derived-type finalization Content-Language: en-US To: Paul Richard Thomas , Harald Anlauf Cc: Alessandro Fanfarillo , Andrew Benson , "fortran@gcc.gnu.org" References: <9a2667e2-8055-bcac-1862-05c8ac60ce7a@gmx.de> <3cbaf568-84ac-8498-558f-9560fe395d66@gmx.de> <7ab973cd-f62e-28be-36e8-4e44252a4a38@gmx.de> From: Thomas Koenig In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-NetCologne-Spam: L X-Rspamd-Queue-Id: 38C5F11F51 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2022 21:23:41 -0000 Hi Paul, > I have gone back to the start and have gone through finalizable derived > type assignments with the F2018 in hand. I have had a dreadful time with > direct by reference function calls and still am struggling with assignment > number 6 in the attached. I would be very grateful if you would run this > testcase for the other brands. This is the output of nagfor 7.1, no idea how correct this is. Best regards Thomas At start of program: final_count = 0 ******************************************************************* 1st assignment: No finalization because MyType unallocated. After 1st assignment(var not allocated): final_count = 0(0) ******************************************************************* 2nd assignment: MyType(=simple(1,MyType) finalized before assignment finalize simple - Mytype2%ind = 1 After 2nd assignment(var allocated): final_count = 1(1) ******************************************************************* 3rd assignment: MyTypeArray(%ind = [41 42]) finalized before assignment finalize simple(:) - MyTypeArray%ind= 42 43 After 3rd assignment(array var allocated): final_count = 1(1) ******************************************************************* Deallocation generates final call with self = simple (21, ThyType) 4th assignment: MyTypeArray finalized before assignment Mtype finalized before assignment with self = simple (11, MyType) Function result finalized after assignment with self = simple (99, MyType) finalize simple - ThyType%ind = 21 finalize simple - MyType%ind = 11 After 4th assignment(array var allocated) :final_count = 2(3) ******************************************************************* 5th assignment: MyTypeArray finalized before assignment 1] First finalization is of 'res' in constructor3 with: Self = [complicated (-1, constructor3, 0.0), complicated (-1, ThyTypeArra1, 0.0)] 2] ThyTypeArray is finalized before assignment and after evaluation of constructor3 Self = [3 times complicated (-1, ThyTypeArra1,0.0)] 3] Function result finalized after assignment with Self = [complicated (-1, ThyTypeArra2, 0.0), complicated (-1, ThyTypeArra2, 0.0)] constructor3: final_count = 0 finalize complicated(2) - constructor3 = 0 0 0.00 0.00 finalize simple(:) - constructor3%ind= 0 0 finalize complicated(3) - ThyTypeArra1 = -1 -1 -1 0.00 0.00 0.00 finalize simple(:) - ThyTypeArra1%ind= -1 -1 -1 finalize complicated(2) - ThyTypeArra2 = 1 3 2.00 4.00 finalize simple(:) - ThyTypeArra2%ind= 1 3 finalize complicated(2) - IypeArra2 = **** 3 2.00 4.00 finalize simple(:) - IypeArra2%ind= **** 3 finalize complicated(2) - IypeArra2 = **** 3 2.00 4.00 finalize simple(:) - IypeArra2%ind= **** 3 After 5th assignment(array var allocated): 10(6) ******************************************************************* Deallocate ThyTypeArray. finalize complicated(2) - ThyTypeArra2 = 1 3 2.00 4.00 finalize simple(:) - ThyTypeArra2%ind= 1 3 ******************************************************************* 6th assignment: A repeat of the previous with an allocatable function result. This should give the same result as the 5th assignment. constructor4: final_count = 0 finalize complicated(2) - constructor4 = 1 1 1.00 1.00 finalize simple(:) - constructor4%ind= 1 1 finalize complicated(2) - ThyTypeArra2 = 1 3 2.00 4.00 finalize simple(:) - ThyTypeArra2%ind= 1 3 finalize complicated(3) - ThyTypeArra1 = -1 -1 -1 0.00 0.00 0.00 finalize simple(:) - ThyTypeArra1%ind= -1 -1 -1 After 6th assignment(array var allocated): 6(6) ******************************************************************* Deallocations at end finalize simple - MyType%ind = 99 After 1st deallocation: 1 finalize simple - ThyType2%ind = 22 After 2nd deallocation: 2 finalize simple(:) - ThyType%ind= 21 22 After 3rd deallocation: 3