http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45424
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-09 15:36:40 UTC --- Created attachment 27359 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27359 Draft patch: is_contiguous.diff Attached is a mostly ready patch for IS_CONTIGUOUS. The main TODO is to understand when IS_CONTIGUOUS should print .TRUE. and when .FALSE. The standard is not very clear about it, cf. 5.3.7 of F2008. a) Array element with nonzero strides (which is still a single array element): "a(1:1:1)" vs. "a(1:1:5)". With the attached patch but also with ifort and crayftn, the result is .true. and .false. The attached patch only checks the "stride", ignoring the number of elements. b) The same - but instead of a single element, using zero-sized arrays: a(2:1:1) vs. a(2:1:2). c) The following example is mishandled as we have a stride and not a stride multiplied (sm): type t integer :: i, j end type t type(t) :: x(5) print *, is_contiguous(x(:)) ! Shall be (and is) true print *, is_contiguous(x(:)%i) ! Shall be false - but prints "true". end The fortran-devel solution would be to use: sm == TYPE_SIZE(a%i). The trunk solution is to compare the array spec's object "a" with the the type-size of "a%i" - and if it differs to abort. d) The gfc_is_simply_contiguous function needs to be refined and extended - and a "gfc_is_simply_noncontiguous" has to be added. e) More tests are needed - including polymorphic arrays and compile-time checks for the code in simplify.c. [Which is related to (d).] f) For TS29113, one needs to handle assumed-rank arrays, including rank-1 ones. Again the question is whether the dummy argument associated with a scalar is then contiguous or not.