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

            Bug ID: 90788
           Summary: ICE on allocating derived type containing class(*)
                    pointer initialized to null()
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: abensonca at gmail dot com
  Target Milestone: ---

The following gives an ICE with trunk:

module vdc
  type:: vdcp
     class(*), pointer :: po => null()
  end type vdcp
end module vdc

module oa
contains
  subroutine i1()
    use :: vdc, only : vdcp
    type(vdcp), pointer :: a, b
    allocate(a)
  end subroutine i1
  subroutine i2()
    use :: vdc, only : vdcp
    type(vdcp), pointer :: a
    allocate(a)
  end subroutine i2
end module oa


$ gfortran -c  tmp.F90 -o tmp.o
tmp.F90:12:0:

   12 |     allocate(a)
      | 
internal compiler error: Segmentation fault
0xde688f crash_signal
        ../../gcc-trunk/gcc/toplev.c:326
0x7fedc334d1ef ???
       
/data001/abenson/Galacticus/Tools/glibc-2.12.1/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x904f94 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc-trunk/gcc/tree.h:3307
0x904f94 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:8360
0x904702 gfc_trans_subcomponent_assign
        ../../gcc-trunk/gcc/fortran/trans-expr.c:8205
0x904fe0 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:8370
0x905e76 gfc_conv_structure(gfc_se*, gfc_expr*, int)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:8437
0x907b25 gfc_trans_assignment_1
        ../../gcc-trunk/gcc/fortran/trans-expr.c:10779
0x9453f8 gfc_trans_allocate(gfc_code*)
        ../../gcc-trunk/gcc/fortran/trans-stmt.c:6663
0x8c34d7 trans_code
        ../../gcc-trunk/gcc/fortran/trans.c:1995
0x8efebb gfc_generate_function_code(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/trans-decl.c:6705
0x8c76c1 gfc_generate_module_code(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/trans.c:2221
0x8773ad translate_all_program_units
        ../../gcc-trunk/gcc/fortran/parse.c:6121
0x8773ad gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:6367
0x8c05ef gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:204
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-pc-linux-gnu/10.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/home/abenson/Galacticus/Tools
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 10.0.0 20190608 (experimental) (GCC) 



The ICE only occurs if there are two subroutines each with an "allocate(a)"
statement - one such subroutine on its own does not trigger the ICE. 

The ICE also goes away if the class(*) pointer is not initialized to null().

Reply via email to