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

            Bug ID: 61527
           Summary: class/extends, multiple generic assignment, accept
                    invalid
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrestelli at gmail dot com

Hi,
   I see that gfortran accepts the following code (even with strict
debug flags) which is ambiguous in the resolution of the generic. The
code is correctly rejected if disp2 uses CLASS(t2) instead of
TYPE(t2), while with TYPE(T2) the code compiles and DISP2 is called,
which I think should not be allowed.


$ gfortran --version
GNU Fortran (GCC) 4.10.0 20140613 (experimental)



module m
 implicit none

 private
 public :: t1, t2, disp

 type :: t1
  integer :: i = 1
 end type t1

 type, extends(t1) :: t2
  real :: r = 2.0
 end type t2

 interface disp
  module procedure disp1, disp2
 end interface

contains

 subroutine disp1(x)
  class(t1), intent(in) :: x
   write(*,*) "Disp 1: ",x%i
 end subroutine disp1

 subroutine disp2(x)
  type(t2), intent(in) :: x ! <- accepted
  !class(t2), intent(in) :: x ! <- rejected
   write(*,*) "Disp 2: ",x%r
 end subroutine disp2

end module m


program p
 use m
 implicit none

 type(t1) :: a
 type(t2) :: b

 call disp(a)
 call disp(b)

end program p

Reply via email to