https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82275
Bug ID: 82275 Summary: gfortran rejects valid & accepts invalid reference to dimension-remapped type selector Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: damian at sourceryinstitute dot org Target Milestone: --- $ cat reproducer.f90 !! Associating a name with a reduced-dimension section of a !! multidimensional array precludes subsequent use of the name !! with the appropriately reduced dimensionality and instead !! requires use of the (invalid) full set of original dimensions. !! It seems that this only occurs in the presence of type guarding: type component end type type container class(component), allocatable :: component_array(:,:) end type type(container) bag type(component) section_copy allocate(component::bag%component_array(1,1)) select type(associate_name=>bag%component_array(1,:)) type is (component) section_copy = associate_name(1) ! gfortran 5,6,7,8 reject valid section_copy = associate_name(1,1)! gfortran 5,6,7,8 accept invalid end select end $ gfortran reproducer.f90 reproducer.f90:16:35: section_copy = associate_name(1) ! gfortran 5,6,7,8 reject valid 1 Error: Rank mismatch in array reference at (1) (1/2) rouson@Sourcery-Linux-VM:~/Desktop/Builds/adhoc/src/gnu/nrc/rank-mismatch$ gfortran --version GNU Fortran (GCC) 8.0.0 20170912 (experimental)