[Bug fortran/87270] "FINAL" subroutine is called when compiled with "gfortran -O1", but not "gfortran -O0"

pault at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 20 18:32:00 GMT 2018


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

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to janus from comment #2)
> (In reply to Dominique d'Humieres from comment #1)
> > This seems to have been fixed by revision r264008 on trunk
> 
> Seems the segfault is 'fixed' due to the fact that the finalizer is not
> called on trunk any more. I get the output:
> 
>  main: check 1
>  create: check 1
>  create: check 2
>  main: check 2
>  create: check 1
>  create: check 2
>  main: check 3
> 
> That's not a proper fix, of course. It rather seems that one bug (the
> segfault) is hidden by another one (namely that the finalizer is not called)
> ?!?

Hmmm! The behaviour is now the same as 7-branch and so the referencing of the
array components using the span field has been fixed.

It seems that finalization has never occurred with any branch for this case,
going back to 6-branch and, looking through trans-decl.c, I cannot see any
point in which finalization would be triggered. I think that the span bug was
causing 'cleanup' to be called erroneously by accessing memory that was not
null (each finalizer call in the code is guarded by a check that the pointer is
non-null.)

I would have to go back to the standard to see what is expected here.

Keep this one waiting.

Cheers

Paul


More information about the Gcc-bugs mailing list