https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109684

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> ---
The trigger for this problem is not apparent to me at all. The chunk that I
mentioned in comment #5 is not responsible for it.

The finalization of 'grid' in 13.f90 is done by an invocation of the
'finalization wrapper', which is an artificial procedure generated in class.cc.
It does the selection of the final procedure, depending on the rank, plus the
finalization of parent types and finalizable components, as required by the
standard.

Apparently, no check was done for the pureness of the finalization_wrapper or
for the final procedures that it invokes. For reasons that I don't understand,
this is being done since my finalization patch, pinpointed in comment #4
(Thanks Tomas!).

The constraint, F2018(C1594), is absolutely clear: "Any procedure referenced in
a pure subprogram, including one referenced via a defined operation, defined
assignment, defined input/output, or finalization, shall be pure." I guess that
the best way to proceed then is to set the finalization wrapper pure if and
only if all the final procedures are pure. I will test other brands to see what
they do. Otherwise, I am warming to my patch, even though it ducks the check.

Paul

Reply via email to