https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87937

            Bug ID: 87937
           Summary: [8/9 Regression] LHS reallocation broken inside
                    "select type"
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tomastrnka at gmx dot com
  Target Milestone: ---

The fix for pr85954 broke LHS reallocation inside "select type" blocks. The
following program segfaults with current 8.2 branch (including the system
compiler 8.2.1 20181011 on my Fedora 29):

program lhsalloc
   type, abstract :: A
      real, allocatable :: x(:)
   end type

   type, extends(A) :: B
   end type

   class(A), allocatable :: t
   real :: y(4)

   y = 1

   allocate(B::t)

   select type (t)
   type is (B)
      t%x = y
   end select

   write(*,*) allocated(t%x)
end program

The code to allocate t%x is simply never generated.

Partially reverting the offending change by removing these two lines from
gfc_is_reallocatable_lhs fixes the issue:

if (sym->attr.associate_var)
  return false;

Although pr87625 sounds related, its fix doesn't help here because the
associate_var check comes earlier.

Reply via email to