http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60717
Bug ID: 60717 Summary: Wrong code with recursive procedure with unlimited polymorphic dummy argument Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: vladimir.fuka at gmail dot com reported on comp.lang.fortran by Thomas Schnurrenberger The output of the two parts of the following program should be the same, as they are with some other compilers (tested with ifort 14). The output with 4.8 and 4.9 is: Output of show_real: 0. 1. 2. 3. 4. 5. 0. 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 2. 3. 4. 5. 3. 4. 5. 4. 5. 5. Output of show_generic: 0. 1. 2. 3. 4. 5. 0. 1. 2. 3. 4. 5. 2. 2. 3. 4. 5. 3. 3. 4. 5. 4. 4. 5. 5. 5. 0. module m ! implicit none ! contains ! recursive subroutine show_real(a) real, intent(in) :: a(:) ! if (size(a) > 0) then print '(10f5.0)', a print '(10f5.0)', a(1) call show_real(a(2:)) end if return end subroutine show_real ! recursive subroutine show_generic(a) class(*), intent(in) :: a(:) ! if (size(a) > 0) then select type (a) type is (real) print '(10f5.0)', a print '(10f5.0)', a(1) end select call show_generic(a(2:)) end if return end subroutine show_generic ! end module m program test ! use :: m ! implicit none ! real :: array(1:6) = (/ 0, 1, 2, 3, 4, 5 /) ! print *, 'Output of show_real:' call show_real(array) print *, 'Output of show_generic:' call show_generic(array) ! end program test