This patch is verging on 'obvious' since there was no attempt being made to detect dimensions where the array reference of the selector is an element. In fact, I made an attempt when the bug was first reported to do this, Not realizing that the elements were coming through as DIMEN_UNKNOWN, the attempt failed. This is now catered for. Bootstrapped and regtested on FC27/x86_64. OK for all active branches? Paul 2018-05-19 Paul Thomas PR fortran/82275 * match.c (gfc_match_type_spec): Go through the array ref and decrement 'rank' for every dimension that is an element. 2018-05-19 Paul Thomas PR fortran/82923 * gfortran.dg/select_type_42.f90: New test.