fortran: IS_CONTIGUOUS correctly returns false for vector-subscripted sections
Fixes Fortran's IS_CONTIGUOUS to return false for array sections using vector subscripts, per F2023.
This commit corrects the behavior of the Fortran intrinsic function IS_CONTIGUOUS. Previously, it incorrectly returned .true. for array sections that used a vector subscript (e.g., A([1,3])). This was because the runtime check examined a temporary array built for such sections, which happened to be contiguous. However, the Fortran 2023 standard specifies that sections with vector subscripts are not contiguous. The fix ensures IS_CONTIGUOUS now returns .false. in these cases, aligning with the standard.
In Details
The IS_CONTIGUOUS intrinsic function in GFortran checks if an array section represents a contiguous block of memory. For array sections with a vector subscript (e.g., array([idx1, idx2, ...])), GFortran would construct a temporary contiguous array and then evaluate IS_CONTIGUOUS on that temporary, yielding .true.. This behavior contradicts F2023 8.5.7, which states such sections are not contiguous. The gfc_simplify_is_contiguous function in simplify.cc is modified to explicitly return .false. when a vector subscript is detected, ensuring compliance with the standard.
- IS_CONTIGUOUS
- A Fortran intrinsic function that returns
.true.if the array argument is contiguous in memory, and.false.otherwise. - Array section
- A portion of an array that can be specified using subscripts, triplet notation, or vector subscripts.
- Vector subscript
- A subscript that is an array itself, used to select elements from another array in a non-sequential manner.
- F2023
- The 2023 revision of the Fortran programming language standard.