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

--- Comment #15 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #14)
> Another tidbit I found is that the array a has the attribute TARGET but
> subcomponents do not.
> 
> So the c => a%x is invalid whereas c => a is valid. This has nothing to do
> with contiguous.
> 
> Regarding contiguous:
> 
> Expression,   Valid as RHS of => ?,     Reason
> 
>      a,                 Yes,            declared target
>      a(3:8),            Yes,            section of target array
>      obj,               Yes,            derived type variable with target
>      obj%comp,          Yes,            component of target variable
>      obj(4)%comp,       Yes,            same
>      obj%comp_array,    No,             whole component array — not TARGET
>      obj_array(:)%comp, No,             very common mistake — same reason
>      local variable
>          without TARGET,No,             compiler error

Where did you get these tidbits?  From Fortran 2018,

  8.5.17 TARGET attribute
  ...
  If an object has the TARGET attribute, then all of its nonpointer
  subobjects also have the TARGET attribute.

  5.4.3.2.1 Data object classification
  ...
  A data object is either a constant, variable, or a subobject of a constant.
  ...
  Subobjects are portions of data objects that can be referenced and defined
  (variables only) independently of the other portions.

  program foo
    type a_t
       integer comp_array(5)
    end type a_t
    type(a_t), target :: obj
    integer, pointer :: x(:)
    obj%comp_array = [1, 2, 3, 4, 5]
    x => obj%comp_array
    print '(*(I0,1X))', x
  end program foo

Am I missing something?

Reply via email to