public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66409] New: Reporting ambiguous interface when overloading assignment with polymorphic array
@ 2015-06-03 20:06 cmacmackin at gmail dot com
  2015-09-13 15:14 ` [Bug fortran/66409] " dominiq at lps dot ens.fr
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: cmacmackin at gmail dot com @ 2015-06-03 20:06 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-10-08 16:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 20:06 [Bug fortran/66409] New: Reporting ambiguous interface when overloading assignment with polymorphic array cmacmackin at gmail dot com
2015-09-13 15:14 ` [Bug fortran/66409] " dominiq at lps dot ens.fr
2022-10-07 13:55 ` jeff.science at gmail dot com
2022-10-07 18:30 ` kargl at gcc dot gnu.org
2022-10-07 19:15 ` anlauf at gcc dot gnu.org
2022-10-07 19:54 ` sgk at troutmask dot apl.washington.edu
2022-10-07 20:10 ` anlauf at gcc dot gnu.org
2022-10-07 20:42 ` mikael at gcc dot gnu.org
2022-10-07 21:02 ` sgk at troutmask dot apl.washington.edu
2022-10-07 21:08 ` mikael at gcc dot gnu.org
2022-10-07 21:12 ` anlauf at gcc dot gnu.org
2022-10-08  6:53 ` jeff.science at gmail dot com
2022-10-08 16:02 ` kargl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).