Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finalization of structure and array constructors

78 views
Skip to first unread message

Paul Richard Thomas

unread,
Dec 15, 2022, 11:39:50 AM12/15/22
to
Hi All,

I am on the point of submitting a patch to correct a number of deficiencies in gfortran's implementation of finalization.

Could somebody please give me some guidance as to how to handle finalization of structure and array constructors?

F2003 (4.5.5.2) When finalization occurs
".....If an executable construct references a structure constructor, the entity created by the structure constructor is finalized after execution of the innermost executable construct containing the reference."
There is no mention of array constructors.

F2008(4.5.6.3) When finalization occurs
".....If an executable construct references a structure constructor or array constructor, the entity created by the constructor is finalized after execution of the innermost executable construct containing the reference."

F2018 and F2023(7.5.6.3) When finalization occurs
There is no mention of finalization of either structure or array constructors.
The introduction says "Finalization of an allocatable subobject during intrinsic assignment has been clarified" and no more about finalization.
The Annexes contain no information about the omission either.

Since I am working with drafts of the two later standards, it is entirely possible that I have missed a correction to the final version of F2018 but I would have expected something to turn up in the F2023 draft.

I have written code to implement finalization of both kind of constructor in gfortran but don't know whether to add these chunks to the patch that I am preparing or to allow them for the appropriate standard and flag them as deleted in F2018.

Thanks in advance for advice.

Paul

FortranFan

unread,
Dec 15, 2022, 12:07:05 PM12/15/22
to
On Thursday, December 15, 2022 at 11:39:50 AM UTC-5, Paul Richard Thomas wrote:

> ..
> I am on the point of submitting a patch to correct a number of deficiencies in gfortran's implementation of finalization.
> ..

@Paul Richard Thomas,

Thank you very much for your effort.

You may also want to announce this at the Fortran Discourse site:
https://fortran-lang.discourse.group/

Since you will find a lot of gfortran users also at the Fortran Discourse site, if you can do anything to entice, teach, mentor, guide such users to collaborate with you on gfortran patches, you can really advance gfortran further and more and more users can become contributors who can maintain and carry forward your legacy with gfortran.

jfh

unread,
Dec 15, 2022, 3:47:09 PM12/15/22
to
Paul seemed to imply that he may not have found all the standard's references to finalization. It may help him that in f2018 finalization appears in Introduction para 2 bulletpoint 2, 3.76, 3.120.4, 7.5.6 Note 1, 7.5.6.2,
7.5.6.3, 10.2.4 C1037, 15.2.1, 15.5.1 para 4, 15.5.4, 15.7 C1584, C1587, C1595, A.2 para 1 bulletpoints 19,20, C.12.5 and the Index.

FortranFan

unread,
Dec 15, 2022, 7:52:21 PM12/15/22
to
On Thursday, December 15, 2022 at 3:47:09 PM UTC-5, jfh wrote:

> ..
> Paul seemed to imply that he may not have found all the standard's references to finalization ..

@jfh,

It's doubtful @Paul Richard Thomas is looking for a listing of the sections where 'finalization' is mentioned in a draft electronic/hard-copy document that might be serving as a proxy for the actual ISO standard. OP is likely aware of and can call on a variety of tools and approaches in the computing domain to assist with such a mundane word processing task in the read mode, but if that's the struggle, then this prior thread at the Fortran Discourse site discussing tools to navigate the PDF document available online such as the J3 Fortran site might be of interest:
https://fortran-lang.discourse.group/t/navigating-the-fortran-standard-document/4597?u=fortranfan

@Paul Richard Thomas' note implies seeking an expert summary of the interpretation of finalization semantics in the standard on a revision by revision (2003 thru' 2018) basis, particularly on the topic of structure and array constructors with guidance on accurate and robust implementation in a compiler viz. gfortran. Hopefully all the sought after information by Paul will be posted here soon to Paul's satisfaction. If not, feedback from some of the other readers at the Fortran Discourse site, who are keen on gfortran as well as conversant with the standard but who don't peruse comp.lang.fortran as much or at all, might prove helpful to Paul. That's why I suggested Paul post there also.

Ev. Drikos

unread,
Dec 16, 2022, 12:03:11 AM12/16/22
to
On 15/12/2022 18:39, Paul Richard Thomas wrote:
> Hi All,
>
> I am on the point of submitting a patch to correct a number of deficiencies in gfortran's implementation of finalization.

Hello,

If you have or can assign in advance a PR number I'd like to add 10+
test cases to it. They are in my gists and some of the results where
adjusted by feedback I received by FortranFan in Fortran Lang Discourse:
https://gist.github.com/drikosev/a9e9e8357dbc45aeb02773198069222b

The actual test cases (realloc_class*) though are in a zip file:
https://github.com/drikosev/pc/blob/master/pc-rules-2021-01-17.tar.bz2

These test cases focus on finalizations that should take place on class
and structure reallocations (the functionality tested isn't for arrays)
and I think perhaps focus on F2018/7.5.6.3 (When finalization occurs).

Sample of these test cases has already been given in PR/64290:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64290#c5


Ev. Drikos

Paul Richard Thomas

unread,
Dec 16, 2022, 2:29:47 AM12/16/22
to
Hi All,

Thank you for the responses and the various pointers. PR64290 is one of the bugs that my coming patch fixes.

Malcolm Cohen kindly pointed me to a correction F08/0011, which eliminates finalization of constructors.

I have, of course, read every single line in the F2018 standard that contains either final or finalization :-)

Regards

Paul
0 new messages