[J3] Finalization Question

Brad Richardson everythingfunctional at protonmail.com
Thu May 26 18:45:56 UTC 2022

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, 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


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?

Brad Richardson

More information about the J3 mailing list