public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46990] New: [OOP] gfortran rejects passing a CLASS variable to TYPE
@ 2010-12-17 10:34 burnus at gcc dot gnu.org
  2010-12-17 20:44 ` [Bug fortran/46990] " janus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-17 10:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46990

           Summary: [OOP] gfortran rejects passing a CLASS variable to
                    TYPE
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


In the following program a polymorphic dummy is passed as actual argument to a
non-polymorphic dummy of the declared type.

The program compiles with the ifort 11.1 and nagf95 5.1, but gfortran rejects
it with:
    call two(x)
             1
Error: Type mismatch in argument 'x' at (1); passed CLASS(t) to TYPE(t)


Both compiler reject passing a CLASS(t2) variable to TYPE(t) or CLASS(t) to
TYPE(t2). (Where "t2" extends type "t".)

 * * *

>From the standard.

"The dummy argument shall be type compatible with the actual argument. If the
actual argument is a polymorphic coindexed object, the dummy argument shall not
be polymorphic." (F2008, 12.5.2.4)

"A nonpolymorphic entity is type compatible only with entities of the same
declared type." (4.3.1.3)

Thus, the dummy argument (a nonpolymorphic entitiy) is type compatible with
entities (i.e. actual actual arguments) of the same declared type.

 * * *

module m
  type t
    integer :: i
  end type t
contains
  subroutine one(x)
    class(t) :: x
    call two(x)
  end subroutine one
  subroutine two(x)
    type(t) :: x
  end subroutine two
end module m


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

end of thread, other threads:[~2011-12-12  8:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-17 10:34 [Bug fortran/46990] New: [OOP] gfortran rejects passing a CLASS variable to TYPE burnus at gcc dot gnu.org
2010-12-17 20:44 ` [Bug fortran/46990] " janus at gcc dot gnu.org
2010-12-17 21:21 ` mikael at gcc dot gnu.org
2010-12-17 21:37 ` janus at gcc dot gnu.org
2010-12-17 22:04 ` janus at gcc dot gnu.org
2010-12-18 16:27 ` janus at gcc dot gnu.org
2010-12-18 17:09 ` burnus at gcc dot gnu.org
2011-02-01  9:27 ` burnus at gcc dot gnu.org
2011-12-11 20:48 ` pault at gcc dot gnu.org
2011-12-12  9:03 ` burnus 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).