https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102106
Bug ID: 102106
Summary: Intermittent Segfault with associate to derived type
with polymorphic component
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: everythingfunctional at protonmail dot com
Target Milestone: ---
I'm using version Ubuntu 11.1.0-1ubuntu1~21.04 on Pop!OS.
The following program segfaults sometimes. I believe this bug specifically has
to do with the association to a return value with a polymorphic component, but
I occasionally see similar errors when associating to more complicated derived
types (i.e. derived types with derived type components, with derived type
components, etc.), even if they aren't polymorphic. I think it only happens if
there is an allocatable component somewhere in the hierarchy though.
I've been encountering this bug (and possibly other related ones) occasionally
for a while now, and was finally able to reproduce it in something small to
hopefully be able to isolate it.
program main
type :: sub_class_t
end type
type :: with_polymorphic_component_t
class(sub_class_t), allocatable :: sub_obj_
end type
associate(obj => with_polymorphic_component_t(sub_class_t()))
end associate
end program
Note: in my testing this segfaults about 1 out of every 10 executions