[Bug fortran/66409] New: Reporting ambiguous interface when overloading assignment with polymorphic array
cmacmackin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 3 20:06:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66409
Bug ID: 66409
Summary: Reporting ambiguous interface when overloading
assignment with polymorphic array
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: cmacmackin at gmail dot com
Target Milestone: ---
I have come across what I believe to be a bug (or possibly a misunderstanding
of the standard on one of our counts) in gfortran. I'm trying to overload the
assignment operator with two custom procedures:
module container_mod
interface assignment(=)
module procedure assign_to_variable
module procedure assign_to_variable_1d
end interface
contains
subroutine assign_to_variable (retval,input)
class(*), intent(inout) :: retval
real, intent(in) :: input
return
end subroutine assign_to_variable
subroutine assign_to_variable_1d (retval_1d,input)
class(*), dimension(:), intent(inout) :: retval_1d
real, intent(in) :: input
return
end subroutine assign_to_variable_1d
end module container_mod
(In the real program where I do this, the input variable is a derived type.)
However, I am getting the compile-time error
gfortran -Wall -c "dbg.f90"
dbg.f90:5.46:
module procedure assign_to_variable_1d
1
Error: Ambiguous interfaces 'assign_to_variable_1d' and
'assign_to_variable' in intrinsic assignment operator at (1)
I've found that ifort 12.1.7.367 and pgfortran 8.0-6 both compile this just
fine. I've also found that, if I change the interface from assignment to just a
normal generic interface, it compiles properly. Finally, if I change the
unlimited polymorphic variables to anything else (a built-in variable type, a
derived type, or a non-unlimited polymorphic variable) it compiled without
problems.
It's also worth noting that, if I try to compile this with only the scalar
interface, gfortran complains when I try to use that to assign to an array. So
obviously the interface is not ambiguous when it comes to actually performing
the assignment.
I hope all of that's clear. I'll be happy to answer any questions or
clarifications.
More information about the Gcc-bugs
mailing list