https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97045
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Paul Thomas <pa...@gcc.gnu.org>: https://gcc.gnu.org/g:fcc4891d7f3bff1a3f7428f12830bc942989306c commit r11-3554-gfcc4891d7f3bff1a3f7428f12830bc942989306c Author: Paul Thomas <pa...@gcc.gnu.org> Date: Wed Sep 30 13:44:39 2020 +0100 This patch fixes PR97045 - unlimited polymorphic array element selectors. 2020-30-09 Paul Thomas <pa...@gcc.gnu.org> gcc/fortran PR fortran/97045 * trans-array.c (gfc_conv_array_ref): Make sure that the class decl is passed to build_array_ref in the case of unlimited polymorphic entities. * trans-expr.c (gfc_conv_derived_to_class): Ensure that array refs do not preceed the _len component. Free the _len expr. * trans-stmt.c (trans_associate_var): Reset 'need_len_assign' for polymorphic scalars. * trans.c (gfc_build_array_ref): When the vptr size is used for span, multiply by the _len field of unlimited polymorphic entities, when non-zero. gcc/testsuite/ PR fortran/97045 * gfortran.dg/select_type_50.f90 : New test.