[Bug fortran/85357] gfortran versions 7.2.0/8.0.1 reject F03 procedure overriding
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 30 05:27:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85357
--- Comment #6 from janus at gcc dot gnu.org ---
(In reply to cfd from comment #5)
> It would be rather surprising if the Fortran standard viewed this as being
> invalid code (the procedure in question is bound to a dervied type,
> hence should
> be overridable).
Note that the error has nothing to do with type binding or overriding at all.
It concerns the name clash of the two subroutines. This reduced version
(without any derived types) shows the same error (and ICE):
module base
implicit none
contains
subroutine summation(i,j)
integer(4), intent(in) :: i
integer(4), intent(out) :: j
j = i + 1
end subroutine
end module base
module extended
use base
implicit none
contains
subroutine summation(i,j)
integer(4), intent(in) :: i
integer(4), intent(out) :: j
j = i + 2
end subroutine
end module extended
You have plenty of options to get around the error:
a) Don't use-import the first 'summation' routine in the second module (as
shown comment 1).
b) Make the 'summation' routines private and only make them available via the
type binding.
c) Use two different names, e.g.
type, abstract :: base_type
contains
procedure :: summation => summation_base
end type base_type
type, extends(base_type) :: extended_type
contains
procedure :: summation => summation__ext
end type extended_type
More information about the Gcc-bugs
mailing list