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

            Bug ID: 90519
           Summary: ICE (segfault) on derived type which has a recursive
                    allocatable component of the same type, and a static
                    component of another type which has a "final"
                    attribute
           Product: gcc
           Version: 7.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: perini at wisc dot edu
  Target Milestone: ---

Created attachment 46372
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46372&action=edit
sample program which reproduces the issue

I'm having an internal compiler error when I try to create a type which
includes:
- a recursive allocatable component of the same type, AND
- at least one NON-allocatable component of another derived type which has a
finalization routine defined by the "final" attribute.

I have tested this on both gfortran 7.1.0 and 7.4.0 and it produces internal
compiler error in both cases: 

internal compiler error: Segmentation fault
0xa8e83f crash_signal
        ../../gcc-7.1.0/gcc/toplev.c:337
0x810e3a expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
        ../../gcc-7.1.0/gcc/expr.c:8065
0x72c446 expand_expr
        ../../gcc-7.1.0/gcc/expr.h:276
0x72c446 expand_call_stmt
        ../../gcc-7.1.0/gcc/cfgexpand.c:2658
0x72c446 expand_gimple_stmt_1
        ../../gcc-7.1.0/gcc/cfgexpand.c:3571
0x72c446 expand_gimple_stmt
        ../../gcc-7.1.0/gcc/cfgexpand.c:3737
0x72d32f expand_gimple_basic_block
        ../../gcc-7.1.0/gcc/cfgexpand.c:5744
0x732496 execute
        ../../gcc-7.1.0/gcc/cfgexpand.c:6357

I have attached a sample program which reproduces the error. 
A few notes about it (please refer to the commented numbered items in the
attached code):  

- type(t) is what causes the compiler to crash. If I define the recursive
component (2) as an allocatable one, the compiler will crash. If I define it as
a pointer (3), it won't. That is a workaround, but I would like to stick to
allocatables, if possible. I don't think I'm violating any standards, am I?

- If I remove the finalization routine (1) from type(t1), which is a static
component of type(t), NOT allocatable, the compiler is able to compile the code
correctly!

- If the finalization routine is inside another allocatable component, like
(4), that does not matter, the compiler always works.

Thanks!
Federico

Reply via email to