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
  2009-10-02  8:42 ` [Bug fortran/41539] " burnus at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ 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] 6+ messages in thread

* [Bug fortran/41539] Calling function which takes CLASS: Rank comparison does not work
  2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
@ 2009-10-02  8:42 ` burnus at gcc dot gnu dot org
  2009-10-05 12:40 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-02  8:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-10-02 08:42 -------
I think the problem occurs in decl.c's

static gfc_try
encapsulate_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
                          gfc_array_spec **as)
{
  [...]
  if (fclass == NULL)
    {
      [...]
      c->attr.dimension = attr->dimension;
      c->as = (*as);
    }
  [...]
  attr->allocatable = attr->pointer = attr->dimension = 0;
  (*as) = NULL;  /* XXX */
  [...]
}

which is called as:
  if (sym->ts.type == BT_CLASS)
    encapsulate_class_symbol (&sym->ts, &sym->attr, &sym->as);


-- 


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


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

* [Bug fortran/41539] Calling function which takes CLASS: Rank comparison does not work
  2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
  2009-10-02  8:42 ` [Bug fortran/41539] " burnus at gcc dot gnu dot org
@ 2009-10-05 12:40 ` burnus at gcc dot gnu dot org
  2010-03-04 15:00 ` [Bug fortran/41539] [OOP] " pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-05 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2009-10-05 12:40 -------
See also review comments http://gcc.gnu.org/ml/fortran/2009-09/msg00298.html
and http://gcc.gnu.org/ml/fortran/2009-09/msg00296.html


-- 


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


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

* [Bug fortran/41539] [OOP] Calling function which takes CLASS: Rank comparison does not work
  2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
  2009-10-02  8:42 ` [Bug fortran/41539] " burnus at gcc dot gnu dot org
  2009-10-05 12:40 ` burnus at gcc dot gnu dot org
@ 2010-03-04 15:00 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-03-04 15:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2010-03-04 15:00 -------
Created an attachment (id=20021)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20021&action=view)
Fixes this bug

This does all the right things, except that the array elements cannot yet be
referenced - another PR, I think?

Paul


-- 


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


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

* [Bug fortran/41539] [OOP] Calling function which takes CLASS: Rank comparison does not work
  2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-03-04 15:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2010-03-04 14:59 -------
Created an attachment (id=20020)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20020&action=view)
Fixes this bug

This does all the right things, except that the array elements cannot yet be
referenced - another PR, I think?

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED


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


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

* [Bug fortran/41539] [OOP] Calling function which takes CLASS: Rank comparison does not work
  2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-03-04 15:00 ` pault at gcc dot gnu dot org
@ 2010-07-15 21:39 ` dfranke at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-07-15 21:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dfranke at gcc dot gnu dot org  2010-07-15 21:39 -------
(From update of attachment 20021)
Obsolete duplicate.


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #20021|0                           |1
        is obsolete|                            |


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


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

end of thread, other threads:[~2010-07-15 21:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-01 22:02 [Bug fortran/41539] New: Calling function which takes CLASS: Rank comparison does not work burnus at gcc dot gnu dot org
2009-10-02  8:42 ` [Bug fortran/41539] " burnus at gcc dot gnu dot org
2009-10-05 12:40 ` 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).