Follow up to PR 41872.

The following program shows at run time:
  Fortran runtime error: Attempting to allocate already allocated array 'a'


  type t
    ! Any scalar/array allocatable component will do for the wrong-code
    integer, allocatable :: d
  end type
  type(t), allocatable :: a
  allocate(a)
end

As:
  struct t * a;
  {
     if (a == NULL) { ...} else { _gfortran_runtime_error_at ... }

There is missing a:
  a = NULL;

 * * *

Another issue: Assume that "a" is not allocated. Then the following will crash:

  if (a->d != 0B)
    {
      __builtin_free ((void *) a->d);
    }
  a->d = 0B;

 * * *

Third issue: There is no automatic deallocation of "a", only of its component
"a%d".


-- 
           Summary: Missed initialization/dealloc of allocatable scalar DT
                    with allocatable component
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 42361
             nThis:


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

Reply via email to