https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123782
--- Comment #9 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #5)
> (In reply to anlauf from comment #4)
> > (In reply to Steve Kargl from comment #3)
> > > This patch allows Ivan's code to compile and execute.
> > > It is otherwise untested.
> > >
> > > diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
> > > index a47e970eda9..4cd90d88050 100644
> > > --- a/gcc/fortran/expr.cc
> > > +++ b/gcc/fortran/expr.cc
> > > @@ -6557,8 +6557,14 @@ gfc_is_not_contiguous (gfc_expr *array)
> > > {
> > > /* Array-ref shall be last ref. */
> > >
> > > - if (ar && ar->type != AR_ELEMENT)
> > > - return true;
> > > + if (ar)
> > > + {
> > > + /* Check for 'a(:)%x' */
> > > + if (ref->type == REF_COMPONENT)
> > > + return gfc_is_simply_contiguous (array, false, false);
> >
> > Is this the right logic? Shouldn't it be inverted?
>
> Good catch. The logic is indeed backwards.
>
> > > + else if (ar->type != AR_ELEMENT)
> > > + return true;
> > > + }
> > >
> > > if (ref->type == REF_ARRAY)
> > > ar = &ref->u.ar;
> >
> > I am still struggling with F2023 8.5.7 CONTIGUOUS attribute, which has:
> >
> > An object is contiguous if it is
> > ...
> > (7) a nonzero‑sized array section (9.5.3) provided that
> > ...
> > (f) only its final part‑ref has nonzero rank, and
> > ...
> >
> > Isn't this violated by the testcase in comment#0?
>
> I think that (7) does not apply here.
>
> c => a%x ! False error?
>
> 'a' is a whole array. Wouldn't (7) apply to something
> like 'c => a(2:3)%x'
So what is the difference between a(:)%x and a(2:3)%x ?
FWIW, Intel says:
pr123782.f90(19): error #8377: An array is not contiguous if any part other
than final has non-zero rank. [X]
c => a%x ! False error?
-------^
pr123782.f90(19): error #8371: If pointer is declared CONTIGUOUS, target must
be contiguous as well. [X]
c => a%x ! False error?
-------^
Does someone want to ask the Intel people for their opinion?
> It seems we have
>
> An object is contiguous if it is
> ...
> (2) a nonpointer whole array that is not assumed-shape,
I found:
9.5.2 Whole arrays
A whole array is a named array or a structure component whose final part‑ref
is an array component name; no subscript list is appended.
Now 'x' is not an array component name, or is it, or do I miss something?
> I suppose one can argument that 'a%x' may not be a whole array;
> in particular, if we have
>
> type :: t1
> real :: x
> integer :: i
> end type
>
> then 3.38 seems to apply.
>
>
> 3.37
> contiguous
> <array> whose array elements, in order, are not separated by other data
> objects
>
> 3.38
> contiguous
> <multi-part data object> whose parts, in order, are not
> separated by other data objects