public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58557] New: [OOP] Issues with CLASS/TYPE functions in array constructors: reject valid, memory leaks, invalid free
@ 2013-09-28  7:43 burnus at gcc dot gnu.org
  2013-09-28  7:50 ` [Bug fortran/58557] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-09-28  7:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58557
           Summary: [OOP] Issues with CLASS/TYPE functions in array
                    constructors: reject valid, memory leaks, invalid free
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: rejects-valid, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org

The following test case shows that functions which return
derived-types/polymorphic arrays are mishandled.


Failures:

* For many: Error: Can't convert REAL(4) to TYPE(t)
* For instance: *(atmp[0].data) = *f_type() ! ups null pointer deref
* Memory not freed for funcs returning allocatable memory.

Note: One problem is that the functions can occur in nested constructors, ac-do
loops, having unknown ac-do loop bounds array sizes.


program main
  implicit none

   type t
   end type t

  interface
    function f_type()
      import :: t
      type(t), allocatable :: f_type
    end function f_type
    function f_type_na()
      import :: t
      type(t) :: f_type
    end function f_type_na
    function f_type_array()
      import :: t
      type(t), allocatable :: f_type(:)
    end function f_type_array
    function f_type_array_na()
      import :: t
      type(t) :: f_type(5)
    end function f_type_array_na
    function f_class(i)
      import :: t
      class(t), allocatable :: f_class
      integer :: i
    end function f_class
    function f_class_array()
      import :: t
      class(t), allocatable :: f_class
      integer :: i
    end function f_class_array
    subroutine sub_type2(x)
      import :: t
      type(t) :: x(:)
    end subroutine sub_type2
    subroutine sub_class2(x)
      import :: t
      class(t) :: x(:)
    end subroutine sub_class2
  end interface

  type(t) :: b(1)
  integer :: i

  b = [ f_type() ]
  b = [ f_type_na() ]
  b = [ f_type_array() ]
  b = [ f_type_array_na() ]
  b = [ f_class_array(1) ]
  call sub_type2([f_class(1)])
  call sub_type2([f_class_array(1)])
  call sub_type2([(f_class(i),i=1,5)])
  call sub_type2([(f_class_array(i),i=1,5)])
  call sub_class2([f_class(1)])
  call sub_class2([f_class_array(1)])
  call sub_class2([(f_class(i),i=1,5)])
  call sub_class2([(f_class_array(i),i=1,5)])
end program main


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

end of thread, other threads:[~2014-01-05 13:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-28  7:43 [Bug fortran/58557] New: [OOP] Issues with CLASS/TYPE functions in array constructors: reject valid, memory leaks, invalid free burnus at gcc dot gnu.org
2013-09-28  7:50 ` [Bug fortran/58557] " burnus at gcc dot gnu.org
2014-01-05 12:41 ` dominiq at lps dot ens.fr
2014-01-05 13:07 ` janus at gcc dot gnu.org
2014-01-05 13:39 ` janus 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).