------- Comment #5 from burnus at gcc dot gnu dot org  2009-06-15 13:09 -------
Juergen: Thanks for the report, but it is not a regression - it might not crash
with 4.3 (or your 4.4) but I think that's just by chance.

Paul, I think also this bug touches code for which you have the expertise.

The problem is the automatic deallocation of an allocatable component. The DT
with this component is returned by a function but treated as variable and not
as function. The crucial part is that the return value is a pointer! If I don't
use a pointer, the dump looks as follows:

    D.1558 = func ();
    sub (&D.1558);
    if (D.1558.a.data != 0B)
        __builtin_free (D.1558.a.data);
    D.1558.a.data = 0B;

with POINTER:

  sub (func ());
  if (func ()->a.data != 0B)
      __builtin_free (func ()->a.data);
  func ()->a.data = 0B;

Testcase:
!--------------------------------------------
  implicit none
  type t
    integer, allocatable :: A(:)
  end type t
  call sub(func())
contains
  function func()
    type(t),pointer :: func
    integer :: i = 0
    if (i /= 0) call abort()
    i = i + 1
  end function func
  subroutine sub(a)
    type(t), intent(IN),target :: a
  end subroutine sub
end


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu dot
                   |                            |org, burnus at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|both MAC OS X Darwin 9.7.0  |
                   |and Linux Debian Edge       |
      Known to fail|4.4.1 4.5.0                 |4.4.1 4.5.0 4.3.3
      Known to work|4.3.3                       |
   Last reconfirmed|0000-00-00 00:00:00         |2009-06-15 13:09:45
               date|                            |
            Summary|[4.4/4.5 Regression] Garbage|Automatic deallocation
                   |or segmentation fault in    |component of DT function
                   |allocatable array derived   |return value
                   |type structures             |


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

Reply via email to