http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57639
Bug ID: 57639 Summary: ICE with polymorphism (and illegal code) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: w6ws at earthlink dot net Bug encountered with a snapshot of todays (June 17, 2013) trunk. The example compiles ok with 'allocatable' attribute specified (and the related allocate statement used) for variables t1 and t2. However if the allocatable attribute is omitted, (and allocate statement removed), gfortran gives a correct error message and then ICEs. module class_mod implicit none contains function compare (a, b) class(*), intent(in), allocatable :: a, b logical :: compare compare = SAME_TYPE_AS (a, b) end function end module program unlimited_test use class_mod implicit none type wws integer :: a, b end type ! When t1 and t2 are given the 'allocatable' attribute, ! and the allocate statement is used, this example compiles ! and runs correctly. However if the 'allocatable' attribute ! and the allocate statement are removed, the compiler issues ! the correct error message and then ICEs. class(*) :: t1, t2 ! allocate (wws::t1, t2) print *, 'main: compare = ', compare (t1, t2) end program wws@w6ws-4:~/fortran/f2008$ gfortran --version GNU Fortran (GCC) 4.9.0 20130617 (experimental) Copyright (C) 2013 Free Software Foundation, Inc. GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING wws@w6ws-4:~/fortran/f2008$ gfortran -c unlimited_test.f90 unlimited_test.f90:29.16: class(*) :: t1, t2 1 Error: CLASS variable 't1' at (1) must be dummy, allocatable or pointer unlimited_test.f90:29.20: class(*) :: t1, t2 1 Error: CLASS variable 't2' at (1) must be dummy, allocatable or pointer f951: internal compiler error: Segmentation fault 0x96fcaf crash_signal ../../gcc-trunk/gcc/toplev.c:333 0x53a009 compare_parameter ../../gcc-trunk/gcc/fortran/interface.c:1982 0x53a009 compare_actual_formal ../../gcc-trunk/gcc/fortran/interface.c:2567 0x53ad33 gfc_procedure_use(gfc_symbol*, gfc_actual_arglist**, locus*) ../../gcc-trunk/gcc/fortran/interface.c:3269 0x585fe0 resolve_specific_f0 ../../gcc-trunk/gcc/fortran/resolve.c:2612 0x585fe0 resolve_specific_f ../../gcc-trunk/gcc/fortran/resolve.c:2637 0x585fe0 resolve_function ../../gcc-trunk/gcc/fortran/resolve.c:2905 0x585fe0 gfc_resolve_expr(gfc_expr*) ../../gcc-trunk/gcc/fortran/resolve.c:6083 0x58bd2b resolve_code ../../gcc-trunk/gcc/fortran/resolve.c:9685 0x58ba7b gfc_resolve_blocks(gfc_code*, gfc_namespace*) ../../gcc-trunk/gcc/fortran/resolve.c:8998 0x58bd09 resolve_code ../../gcc-trunk/gcc/fortran/resolve.c:9675 0x58e8be resolve_codes ../../gcc-trunk/gcc/fortran/resolve.c:14464 0x57fe82 gfc_resolve ../../gcc-trunk/gcc/fortran/resolve.c:14492 0x5749aa resolve_all_program_units ../../gcc-trunk/gcc/fortran/parse.c:4442 0x5749aa gfc_parse_file() ../../gcc-trunk/gcc/fortran/parse.c:4691 0x5b0a45 gfc_be_parse_file ../../gcc-trunk/gcc/fortran/f95-lang.c:189 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. wws@w6ws-4:~/fortran/f2008$