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

            Bug ID: 86325
           Summary: Error on valid code with pointer class components
                    using -finit-derived
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foreese at gcc dot gnu.org
  Target Milestone: ---

gfortran reports an error for valid code which uses class pointer components
when compiling with -finit-derived:

$ cat init_flag_19.f03

implicit none

type :: ty1
  integer :: ival
  real    :: rval
end type

type :: ty2
  type(ty1)               :: bt
  type(ty1), allocatable  :: bt_alloc
  type(ty1), pointer      :: bt_ptr
  class(ty1), allocatable :: class_alloc
  class(ty1), pointer     :: class_ptr
end type

type(ty2) basic
class(ty1), allocatable :: calloc

print *, basic%bt%ival
print *, calloc%ival

end

$ gfortran -finit-derived init_flag_19.f03

init_flag_19.f03:9:11:

 type :: ty1
           1
Error: Pointer assignment target is neither TARGET nor POINTER at (1)
init_flag_19.f03:19:38:

   class(ty1), pointer     :: class_ptr
                                      1
Error: Pointer assignment target is neither TARGET nor POINTER at (1)
init_flag_19.f03:9:11:

 type :: ty1
           1
Error: The element in the structure constructor at (1), for pointer component
‘bt_ptr’ should be a POINTER or a TARGET
init_flag_19.f03:9:11:

 type :: ty1
           1
Error: Pointer initialization target at (1) must have the SAVE attribute



The issue is present from the introduction of -finit-derived in 7.1 through 8.x
and trunk.

Reply via email to