[J3] Finalization Question

Malcolm Cohen malcolm at nag-j.co.jp
Fri May 27 04:38:25 UTC 2022


No, structure constructors are not finalised, whether in a specification expression or not.

 

This was corrected by interp F08/0011 in F2008 Corrigendum 1.

 

That interp states explicitly “Constructors don't do anything that needs finalization.

Edits are provided to correct the mistake.”

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Steve Lionel via J3
Sent: Friday, May 27, 2022 5:02 AM
To: j3 at mailman.j3-fortran.org
Cc: Steve Lionel <steve at stevelionel.com>
Subject: Re: [J3] Finalization Question

 

F03/0007, https://j3-fortran.org/doc/year/04/04-332.txt (In F03 Corrigendum 1)

 

Excerpt:

 

Yes, structure constructors in specification expressions are
finalized.  Just as with function results in specification
expressions, this finalization occurs before execution of the
executable constructs in the scoping unit.  This was an accidental
omission from the standard.  Edits are supplied to correct it.

 

 

 

 

 

On 5/26/2022 2:45 PM, Brad Richardson via J3 wrote:

Hi All,
 
Recently we were attempting to write a suite of tests to check
compilers for conformance to the standard with regards to finalization.
In Section 7.5.6.3, paragraph 6 states:
 
If a specification expression in a scoping unit references a function,
the result is finalized before execution of the executable constructs
in the scoping unit.
 
We attempted to test this doing something like the following:
 
subroutine finalize_specification_expression
  character(len=size([object_t()])) :: string
end subroutine
 
No compiler we tried executed the final subroutine of object_t (some
couldn't even compile that statement). We submitted a bug report to one
compiler team, and received a response that:
 
A structure constructor is not a function reference, so this does not
apply.
 
And
 
Structure constructors and array constructors are never finalised.
There is no explicit rule stating this, it is a consequence of the
standard never saying that they are finalised.
 
So the question then is:
 
Is there any possible function that could be used in a specification
expression, that would return a type that has a final subroutine?
 
I'm leaning towards no there isn't. The only place I believe a
specification expression appears is in a type-spec (maybe in an
attribute of a declaration?), which, as the standard does say, means it
is a constant expression. Since only certain intrinsic functions can
appear in constant expressions, I'm failing to see how this paragraph
could ever apply.
 
What do you all think?
 
Regards,
Brad Richardson
 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220527/60ec77c1/attachment-0001.htm>


More information about the J3 mailing list