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

--- Comment #6 from John Haiducek <jhaiduce at gmail dot com> ---
I encountered what appears to be the same bug under slightly different
conditions; I've attached the corresponding code (see attachment named
"Additional test case"). In this code the crash occurs when finalizing an
object of a type that inherits from a parent type, where the child type has no
data members of its own.

There are several workarounds that prevent the segmentation fault in this test:
- Create the object with the default constructor rather than using a custom
constructor
- Add a data member to the child type
- Remove the final routine from the child type

I posted the code in the attached "Additional test case" on the Fortran
Discourse (see discussion at
https://fortran-lang.discourse.group/t/segmentation-fault-when-finalizing-an-inherited-type-with-custom-constructor/7319).
>From the discussion it was determined that this code triggers a segmentation
fault with the following compiler/OS combinations:
- gfortran 13.2.0 on Ubuntu 23.10 and FreeBSD 14.0
- gfortran 13.2.1 on Fedora 38
- gfortran 13.2.0-13.2.1 on MacOS (arm)

The segmentation fault does not occur on the following compiler/OS
combinations:
- gfortran 11.4.0 on Ubuntu 23.10
- gfortran 12.2.0 on FreeBSD 14.0
- gfortran 14.0.1 experimental on Windows (but in this case there are still
indications of incorrect behavior; no segfault occurred but a print statement
added to the end of the code did not produce any output)

The program also reportedly runs as expected when compiled with ifort.

Reply via email to