public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41539]  New: Calling function which takes CLASS: Rank comparison does not work
@ 2009-10-01 22:02 burnus at gcc dot gnu dot org
  2010-03-04 15:00 ` [Bug fortran/41539] [OOP] " pault at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-01 22:02 UTC (permalink / raw)
  To: gcc-bugs

The following program compiles with ifort and with NAG f95 but fails with
gfortran with:

  call qsort(A,tmp)
             1
Error: Rank mismatch in argument 'a' at (1) (0 and 1)


( The program was motivated by
http://groups.google.com/group/comp.lang.fortran/msg/cde7f6104f6c29c7 )


module m_qsort
  implicit none
  type, abstract :: sort_t
  contains
    procedure(lt_cmp), deferred :: lt_cmp
  end type sort_t
  interface
    logical function lt_cmp(a,b)
      import
      class(sort_t), intent(in) :: a, b
    end function lt_cmp
  end interface
contains
  subroutine qsort(a,tmp)
    class(sort_t), intent(inout) :: a(:),tmp
    ! Fixme: Replace "tmp" by a local var and "allocate(tmp, source=a)"
  end subroutine qsort
end module m_qsort

module test
  use m_qsort
  implicit none
  type, extends(sort_t) :: sort_int_t
    integer :: i
  contains
    procedure :: lt_cmp => lt_cmp_int
  end type
contains
  logical function lt_cmp_int(a,b) result(cmp)
    class(sort_int_t), intent(in) :: a
    class(sort_t), intent(in) :: b
    select type(b)
      type is(sort_int_t)
        if (a%i < b%i) then
          cmp = .true.
        else
          cmp = .false.
        end if
      class default
        stop 'Something went wrong'
    end select
  end function lt_cmp_int
end module test

program main
  use test
  type(sort_int_t) :: A(5), tmp
  A(:)%i = [1 , 4, 5, 2, 3]
  print *, A
  call qsort(A,tmp)
  print *, A
end program main


-- 
           Summary: Calling function which takes CLASS: Rank comparison does
                    not work
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-41539-4@http.gcc.gnu.org/bugzilla/>
2011-12-11 20:45 ` [Bug fortran/41539] [OOP] Calling function which takes CLASS: Rank comparison does not work pault at gcc dot gnu.org
2011-12-12  8:03 ` burnus at gcc dot gnu.org
2009-10-01 22:02 [Bug fortran/41539] New: " burnus at gcc dot gnu dot org
2010-03-04 15:00 ` [Bug fortran/41539] [OOP] " pault at gcc dot gnu dot org
2010-03-04 15:00 ` pault at gcc dot gnu dot org
2010-07-15 21:39 ` dfranke at gcc dot gnu dot 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).