..
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). ..
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 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)
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."
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).
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?:
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."
..
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.
..
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:16:41 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,579 |