http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56266
Bug #: 56266 Summary: ICE on invalid in gfc_match_varspec Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: abenso...@gmail.com The following causes an ICE with trunk (and 4.6 and 4.7): module t type nc contains procedure :: encM => em end type nc contains double precision function em(self) implicit none class (nc), intent(inout) :: c em=0.0d0 return end function em double precision function cem(c) implicit none class (nc), intent(inout) :: c cem=c(i)%encM() return end function cem end program p $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-unknown- linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure -- prefix=/home/abenson/Galacticus/Tools --enable-languages=c,c++,fortran -- disable-multilib --with-gmp=/home/abenson/Galacticus/Tools Thread model: posix gcc version 4.8.0 20130208 (experimental) (GCC) $ gfortran -o bug.exe bug.F90 f951: internal compiler error: in gfc_match_varspec, at fortran/primary.c:1960 0x540478 gfc_match_varspec(gfc_expr*, int, bool, bool) ../../gcc-trunk/gcc/fortran/primary.c:1957 0x541a99 gfc_match_rvalue(gfc_expr**) ../../gcc-trunk/gcc/fortran/primary.c:3118 0x528d8e match_primary ../../gcc-trunk/gcc/fortran/matchexp.c:157 0x528d8e match_level_1 ../../gcc-trunk/gcc/fortran/matchexp.c:211 0x528d8e match_mult_operand ../../gcc-trunk/gcc/fortran/matchexp.c:265 0x528fc8 match_add_operand ../../gcc-trunk/gcc/fortran/matchexp.c:354 0x5292e4 match_level_2 ../../gcc-trunk/gcc/fortran/matchexp.c:478 0x529382 match_level_3 ../../gcc-trunk/gcc/fortran/matchexp.c:549 0x529495 match_level_4 ../../gcc-trunk/gcc/fortran/matchexp.c:597 0x529495 match_and_operand ../../gcc-trunk/gcc/fortran/matchexp.c:691 0x529652 match_or_operand ../../gcc-trunk/gcc/fortran/matchexp.c:720 0x529742 match_equiv_operand ../../gcc-trunk/gcc/fortran/matchexp.c:763 0x529834 match_level_5 ../../gcc-trunk/gcc/fortran/matchexp.c:809 0x528be1 gfc_match_expr(gfc_expr**) ../../gcc-trunk/gcc/fortran/matchexp.c:868 0x522631 gfc_match(char const*, ...) ../../gcc-trunk/gcc/fortran/match.c:1103 0x523b19 gfc_match_assignment() ../../gcc-trunk/gcc/fortran/match.c:1301 0x537449 match_word ../../gcc-trunk/gcc/fortran/parse.c:65 0x537bdb match_word ../../gcc-trunk/gcc/fortran/parse.c:326 0x537bdb decode_statement ../../gcc-trunk/gcc/fortran/parse.c:326 0x539194 next_free ../../gcc-trunk/gcc/fortran/parse.c:777 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. This is with gfortran 4.8.0 r195874 The code is invalid because of this line: cem=c(i)%encM() both because "c" is not an array, and "i" is not declared (and the function is "IMPLICIT NONE")