http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47399
Summary: ICE with TBP of a PARAMETER Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: ja...@gcc.gnu.org Found by Wolfgang Kilian, cf http://groups.google.com/group/comp.lang.fortran/msg/e6a865eda59e86db (Whole c.l.f thread: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/69220fdd4c2715c0 ) The following program ICEs for variant #3, where one uses a TBP of a PARAMETER. The variants #1 and #2 compile with -std=f2003/f2008/gnu and print "13". Variant #1 with the TBP comment out compiles also with -std=f95. The ICE is by definition wrong. I have not checked whether the program is valid or not. My feeling is that variant #1 (with TBP comment) is at least invalid in -std=f95, but I might be wrong. Ifort fails with: "An automatic object is invalid in a main program." If this is not changed and applies here, one should check for it using a subroutine and not a main program. -- If one does so, ifort compiles #1 and #3 but rejects #2. NAG v5.1 does the same for the subroutine version. gfortran behaves identical for program and subroutine. TODO: a) Fix ICE b) Check whether the code is valid Fortran 2008 c) Check whether some diagnostic is needed for Fortran 95/2003/2008 d) Do (b) and (c) for program replaced by subroutine. The ICE is: test.f90:19:0: internal compiler error: in gfc_match_varspec, at fortran/primary.c:1846 module mytypes implicit none private public :: mytype, get_i integer, save :: i_priv = 13 type :: mytype integer :: dummy contains procedure, nopass :: i => get_i end type mytype contains pure function get_i () result (i) integer :: i i = i_priv end function get_i end module mytypes program test use mytypes implicit none type(mytype) :: a type(mytype), parameter :: a_const = mytype (0) ! integer, dimension (get_i()) :: x ! #1 ! integer, dimension (a%i()) :: x ! #2 integer, dimension (a_const%i()) :: x ! #3 print *, size (x) end program test