Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"I'm growing older, but not up." -- Jimmy Buffett


devel / comp.lang.fortran / Re: Finalization with defined assignment

SubjectAuthor
* Finalization with defined assignmentThomas Koenig
+* Re: Finalization with defined assignmentFortranFan
|`* Re: Finalization with defined assignmentThomas Koenig
| +* Re: Finalization with defined assignmentJRR
| |`- Re: Finalization with defined assignmentThomas Koenig
| `* Re: Finalization with defined assignmentThomas Koenig
|  `* Re: Finalization with defined assignmentFortranFan
|   `- Re: Finalization with defined assignmentThomas Koenig
`- Re: Finalization with defined assignmentJRR

1
Finalization with defined assignment

<tctsc9$pg3$3@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2674&group=comp.lang.fortran#2674

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Finalization with defined assignment
Date: Tue, 9 Aug 2022 14:52:57 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tctsc9$pg3$3@newsreader4.netcologne.de>
Injection-Date: Tue, 9 Aug 2022 14:52:57 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e87a:0:7285:c2ff:fe6c:992d";
logging-data="26115"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Tue, 9 Aug 2022 14:52 UTC

I have a question on finalization. The following program prints
different things with different compilers, and I wonder which
is correct. (The "assignment" is a bit strange to better see what
is going on). One output I get is (xlf and nagfor)

to_foo 3
assign 4
cleanup 3
cleanup 4

and the other one (gfortran)

to_foo 3
assign 4
cleanup 4

Now, if I look at where all the action is occuring,

a = to_foo(3)

this is not an intrinsic assignment, but rather a defined
assignment. Looking at "7.5.6.3 When finalization occurs", I do
not see defined assignment in the list. So, my conclusion would
be that cleanup should only be called once. (I am not sure that
this would be convenient, but it would be according to what I read
in the standard).

So, what is right? Or did I miss an erratum?

module y
implicit none
type foo
integer :: n
contains
final :: cleanup
end type foo
interface assignment (=)
module procedure assign
end interface assignment (=)
contains

subroutine assign (rop, op)
type(foo), intent(inout) :: rop
type(foo), intent(in) :: op
rop%n = op%n + 1
print '(A12,I3)',"assign", rop%n
end subroutine assign

function to_foo(n) result(res)
integer, intent(in) :: n
type (foo) :: res
res%n = n
print '(A12,I3)', "to_foo", res%n
end function to_foo

subroutine cleanup (self)
type (foo), intent(inout) :: self
print '(A12,I3)', "cleanup", self%n
end subroutine cleanup
end module y

program memain
use y
implicit none
call chk
contains
subroutine chk
type (foo) :: a
a = to_foo(3)
end subroutine chk
end program memain

Re: Finalization with defined assignment

<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2675&group=comp.lang.fortran#2675

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:1c83:b0:46b:a79a:2f0b with SMTP id ib3-20020a0562141c8300b0046ba79a2f0bmr21242036qvb.103.1660080484908;
Tue, 09 Aug 2022 14:28:04 -0700 (PDT)
X-Received: by 2002:a81:75d7:0:b0:328:297a:2f7d with SMTP id
q206-20020a8175d7000000b00328297a2f7dmr25442739ywc.313.1660080484617; Tue, 09
Aug 2022 14:28:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 9 Aug 2022 14:28:04 -0700 (PDT)
In-Reply-To: <tctsc9$pg3$3@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.39.92; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.39.92
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
Subject: Re: Finalization with defined assignment
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Tue, 09 Aug 2022 21:28:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2242
 by: FortranFan - Tue, 9 Aug 2022 21:28 UTC

On Tuesday, August 9, 2022 at 10:53:00 AM UTC-4, Thomas Koenig wrote:

> ..
> this is not an intrinsic assignment, but rather a defined
> assignment. Looking at "7.5.6.3 When finalization occurs", I do
> not see defined assignment in the list. So, my conclusion would
> be that cleanup should only be called once. (I am not sure that
> this would be convenient, but it would be according to what I read
> in the standard). ..

At first glance at the code (I did not copy and paste it to try it with Intel Fortran), the following in the standard appears applicable, "A nonpointer, nonallocatable object that is not a dummy argument or function result is finalized immediately before it would become undefined due to execution of a RETURN or END statement (19.6.6, item (3))."

From the output you show, it appears gfortran fails to finalize the function result i.e., the object created toward 'res' in the 'to_foo' function.

You might find outstanding bug reports toward finalization in gfortran Bugzilla that refer to the same or similar cases.

Re: Finalization with defined assignment

<td03qq$mrk$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2676&group=comp.lang.fortran#2676

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Wed, 10 Aug 2022 11:12:26 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <td03qq$mrk$1@newsreader4.netcologne.de>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
Injection-Date: Wed, 10 Aug 2022 11:12:26 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e87a:0:7285:c2ff:fe6c:992d";
logging-data="23412"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 10 Aug 2022 11:12 UTC

FortranFan <parekhvs@gmail.com> schrieb:
> On Tuesday, August 9, 2022 at 10:53:00 AM UTC-4, Thomas Koenig wrote:
>
>> ..
>> this is not an intrinsic assignment, but rather a defined
>> assignment. Looking at "7.5.6.3 When finalization occurs", I do
>> not see defined assignment in the list. So, my conclusion would
>> be that cleanup should only be called once. (I am not sure that
>> this would be convenient, but it would be according to what I read
>> in the standard). ..
>
> At first glance at the code (I did not copy and paste it to try
> it with Intel Fortran), the following in the standard appears
> applicable, "A nonpointer, nonallocatable object that is not a
> dummy argument or function result is finalized immediately before it
> would become undefined due to execution of a RETURN or END statement
> (19.6.6, item (3))."

I saw that, but it did not seem to apply due to the definition of a
function result in 5.4.3.1: "A data entity that is the result of the
execution of a function reference is called the function result."

It is also strange because the object that is returned does
not become undefined due to RETURN or END. Rather it becomes
inaccessible (and could be defined to become undefined) once the
assignment is complete.

I am more than happy with nagfor's and xlf's behavior, because it
certainly is the right thing to do, but I have not yet to find
a justification for it in the standard.

Also, I do not see a change in 22-007r1.

(And taken note 1 to 7.5.6.3 into account, it would make no sense
_not_ to finalize).

Re: Finalization with defined assignment

<td0bl9$ubn$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2677&group=comp.lang.fortran#2677

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!NCxPy/hiXvU+XhkgncQEkQ.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Wed, 10 Aug 2022 15:26:01 +0200
Organization: Aioe.org NNTP Server
Message-ID: <td0bl9$ubn$1@gioia.aioe.org>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="31095"; posting-host="NCxPy/hiXvU+XhkgncQEkQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.1.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: JRR - Wed, 10 Aug 2022 13:26 UTC

Am 09.08.22 um 16:52 schrieb Thomas Koenig:
> I have a question on finalization. The following program prints
> different things with different compilers, and I wonder which
> is correct. (The "assignment" is a bit strange to better see what
> is going on). One output I get is (xlf and nagfor)
>
> to_foo 3
> assign 4
> cleanup 3
> cleanup 4
>
> and the other one (gfortran)
>
> to_foo 3
> assign 4
> cleanup 4
>
> Now, if I look at where all the action is occuring,
>
> a = to_foo(3)
>

Hi Thomas,
just as a quick check (then I will look in the standard myself),
Intel (v2021.5.0) supports the first version, while Nvidia (v22.3)
has yet another option:
$ nvfortran final.f90
reuter@t00pcx29380:~$ ./a.out
cleanup 0
to_foo 3
assign 4
cleanup 4
Cheers,
JRR

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron (DESY)
Hamburg, Germany

Re: Finalization with defined assignment

<td0njr$c3f$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2678&group=comp.lang.fortran#2678

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!NCxPy/hiXvU+XhkgncQEkQ.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Wed, 10 Aug 2022 18:50:03 +0200
Organization: Aioe.org NNTP Server
Message-ID: <td0njr$c3f$1@gioia.aioe.org>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
<td03qq$mrk$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="12399"; posting-host="NCxPy/hiXvU+XhkgncQEkQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.1.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: JRR - Wed, 10 Aug 2022 16:50 UTC

Am 10.08.22 um 13:12 schrieb Thomas Koenig:
> FortranFan <parekhvs@gmail.com> schrieb:
>> On Tuesday, August 9, 2022 at 10:53:00 AM UTC-4, Thomas Koenig wrote:
>>
..
>>
>> At first glance at the code (I did not copy and paste it to try
>> it with Intel Fortran), the following in the standard appears
>> applicable, "A nonpointer, nonallocatable object that is not a
>> dummy argument or function result is finalized immediately before it
>> would become undefined due to execution of a RETURN or END statement
>> (19.6.6, item (3))."
>
> I saw that, but it did not seem to apply due to the definition of a
> function result in 5.4.3.1: "A data entity that is the result of the
> execution of a function reference is called the function result."
>

I would say that 7.5.6.3.7 applies (a function result is an intent(out)
dummy argument of a procedure), 7.5.6.3.3 explicitly excludes function
results, or?:
"When a procedure is invoked, a nonpointer, nonallocatable, INTENT (OUT)
dummy argument of that procedure is finalized before it becomes undefined."
and then 19.6.6.15 c) applies:
"When a procedure is invoked an actual argument corresponding to a dummy
argument with INTENT (OUT) becomes undefined except for" [....any
nonpointer default-initialized subcomponents of the argument (doesn't
apply)],
An actual argument R1524 is one
entity (R1524) that appears in a procedure reference,
with
procedure reference
"appearance of a procedure designator, operator symbol, or assignment
symbol in a context requiring execution of the procedure at that point
during execution; or occurrence of defined input/output (13.7.6) or
derived-type finalization (7.5.6.2)"

> It is also strange because the object that is returned does
> not become undefined due to RETURN or END. Rather it becomes
> inaccessible (and could be defined to become undefined) once the
> assignment is complete.
>
> I am more than happy with nagfor's and xlf's behavior, because it
> certainly is the right thing to do, but I have not yet to find
> a justification for it in the standard.
>
> Also, I do not see a change in 22-007r1.
>
> (And taken note 1 to 7.5.6.3 into account, it would make no sense
> _not_ to finalize).

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron (DESY)
Hamburg, Germany

Re: Finalization with defined assignment

<td17qb$o6f$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2679&group=comp.lang.fortran#2679

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Wed, 10 Aug 2022 21:26:35 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <td17qb$o6f$1@newsreader4.netcologne.de>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
<td03qq$mrk$1@newsreader4.netcologne.de> <td0njr$c3f$1@gioia.aioe.org>
Injection-Date: Wed, 10 Aug 2022 21:26:35 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e87a:0:7285:c2ff:fe6c:992d";
logging-data="24783"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 10 Aug 2022 21:26 UTC

JRR <juergen.reuter@invalid.com> schrieb:
> Am 10.08.22 um 13:12 schrieb Thomas Koenig:
>> FortranFan <parekhvs@gmail.com> schrieb:
>>> On Tuesday, August 9, 2022 at 10:53:00 AM UTC-4, Thomas Koenig wrote:
>>>
> ..
>>>
>>> At first glance at the code (I did not copy and paste it to try
>>> it with Intel Fortran), the following in the standard appears
>>> applicable, "A nonpointer, nonallocatable object that is not a
>>> dummy argument or function result is finalized immediately before it
>>> would become undefined due to execution of a RETURN or END statement
>>> (19.6.6, item (3))."
>>
>> I saw that, but it did not seem to apply due to the definition of a
>> function result in 5.4.3.1: "A data entity that is the result of the
>> execution of a function reference is called the function result."
>>
>
> I would say that 7.5.6.3.7 applies (a function result is an intent(out)
> dummy argument of a procedure),

A function result is not an intent(out) dummy argument. They have
some similarities, but are defined to be different constructs.

It is not, for example, possible to pass an actual argument to
a function result, as you could with an intent(out) variable.

>7.5.6.3.3 explicitly excludes function
> results, or?:

Yes, it does. But I'm not quite clear what that entails.

[...]

Re: Finalization with defined assignment

<td7kq3$qq$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2682&group=comp.lang.fortran#2682

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Sat, 13 Aug 2022 07:45:07 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <td7kq3$qq$1@newsreader4.netcologne.de>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
<td03qq$mrk$1@newsreader4.netcologne.de>
Injection-Date: Sat, 13 Aug 2022 07:45:07 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e87a:0:7285:c2ff:fe6c:992d";
logging-data="858"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sat, 13 Aug 2022 07:45 UTC

Thomas Koenig <tkoenig@netcologne.de> schrieb:
> FortranFan <parekhvs@gmail.com> schrieb:
>> On Tuesday, August 9, 2022 at 10:53:00 AM UTC-4, Thomas Koenig wrote:
>>
>>> ..
>>> this is not an intrinsic assignment, but rather a defined
>>> assignment. Looking at "7.5.6.3 When finalization occurs", I do
>>> not see defined assignment in the list. So, my conclusion would
>>> be that cleanup should only be called once. (I am not sure that
>>> this would be convenient, but it would be according to what I read
>>> in the standard). ..
>>
>> At first glance at the code (I did not copy and paste it to try
>> it with Intel Fortran), the following in the standard appears
>> applicable, "A nonpointer, nonallocatable object that is not a
>> dummy argument or function result is finalized immediately before it
>> would become undefined due to execution of a RETURN or END statement
>> (19.6.6, item (3))."
>
> I saw that, but it did not seem to apply due to the definition of a
> function result in 5.4.3.1: "A data entity that is the result of the
> execution of a function reference is called the function result."

Ah, I think I see the source of my misunderstanding.

In

function foo() result(res)
integer :: res
end function foo

res is the function result, but when invoking the function
in an expression, foo() is _not_ the function result.

Standardese...

Re: Finalization with defined assignment

<70543f08-6541-4c16-989c-f05ef7ceed9cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2686&group=comp.lang.fortran#2686

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a0c:8ecc:0:b0:473:2fa4:df7c with SMTP id y12-20020a0c8ecc000000b004732fa4df7cmr7221054qvb.55.1660400124536;
Sat, 13 Aug 2022 07:15:24 -0700 (PDT)
X-Received: by 2002:a0d:e6d2:0:b0:328:3bae:356f with SMTP id
p201-20020a0de6d2000000b003283bae356fmr7633858ywe.457.1660400124107; Sat, 13
Aug 2022 07:15:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Sat, 13 Aug 2022 07:15:23 -0700 (PDT)
In-Reply-To: <td7kq3$qq$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.39.107; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.39.107
References: <tctsc9$pg3$3@newsreader4.netcologne.de> <a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
<td03qq$mrk$1@newsreader4.netcologne.de> <td7kq3$qq$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <70543f08-6541-4c16-989c-f05ef7ceed9cn@googlegroups.com>
Subject: Re: Finalization with defined assignment
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Sat, 13 Aug 2022 14:15:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2281
 by: FortranFan - Sat, 13 Aug 2022 14:15 UTC

On Saturday, August 13, 2022 at 3:45:13 AM UTC-4, Thomas Koenig wrote:

> ..
> > FortranFan schrieb:
> ..
> >> At first glance at the code (I did not copy and paste it to try
> >> it with Intel Fortran), the following in the standard appears
> >> applicable, "A nonpointer, nonallocatable object that is not a
> >> dummy argument or function result is finalized immediately before it
> >> would become undefined due to execution of a RETURN or END statement
> >> (19.6.6, item (3))."
> ..
> Ah, I think I see the source of my misunderstanding.
>
> In
>
> function foo() result(res)
> integer :: res
> end function foo
>
> res is the function result, but when invoking the function
> in an expression, foo() is _not_ the function result.
> ..

Glad you figured it out.

Please see the following link, perhaps you will touch base with Andrew (@abe...@carnegiescience.edu) and Paul Richard Thomas on enhancements to gfortran:
https://groups.google.com/g/comp.lang.fortran/c/n8Y4QX1_3tI/m/keJG5yFNAQAJ

Re: Finalization with defined assignment

<td8g3v$iqo$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2687&group=comp.lang.fortran#2687

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Finalization with defined assignment
Date: Sat, 13 Aug 2022 15:31:11 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <td8g3v$iqo$1@newsreader4.netcologne.de>
References: <tctsc9$pg3$3@newsreader4.netcologne.de>
<a156b8aa-4a15-4da7-8f44-b78774877439n@googlegroups.com>
<td03qq$mrk$1@newsreader4.netcologne.de>
<td7kq3$qq$1@newsreader4.netcologne.de>
<70543f08-6541-4c16-989c-f05ef7ceed9cn@googlegroups.com>
Injection-Date: Sat, 13 Aug 2022 15:31:11 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-e87a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:e87a:0:7285:c2ff:fe6c:992d";
logging-data="19288"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sat, 13 Aug 2022 15:31 UTC

FortranFan <parekhvs@gmail.com> schrieb:
> On Saturday, August 13, 2022 at 3:45:13 AM UTC-4, Thomas Koenig wrote:
>
>> ..
>> > FortranFan schrieb:
>> ..
>> >> At first glance at the code (I did not copy and paste it to try
>> >> it with Intel Fortran), the following in the standard appears
>> >> applicable, "A nonpointer, nonallocatable object that is not a
>> >> dummy argument or function result is finalized immediately before it
>> >> would become undefined due to execution of a RETURN or END statement
>> >> (19.6.6, item (3))."
>> ..
>> Ah, I think I see the source of my misunderstanding.
>>
>> In
>>
>> function foo() result(res)
>> integer :: res
>> end function foo
>>
>> res is the function result, but when invoking the function
>> in an expression, foo() is _not_ the function result.
>> ..
>
> Glad you figured it out.
>
> Please see the following link, perhaps you will touch base with Andrew (@abe...@carnegiescience.edu) and Paul Richard Thomas on enhancements to gfortran:
> https://groups.google.com/g/comp.lang.fortran/c/n8Y4QX1_3tI/m/keJG5yFNAQAJ

I've already started work on that myself, let's see how far I get
(or if I am even on the right track), but discussing with
Paul is definitely on the agenda :-)

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor