https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103474
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:22d710cc5f40d79aab104ec5fb5fe97386d56d8a commit r17-4205-g22d710cc5f40d79aab104ec5fb5fe97386d56d8a Author: Jerry DeLisle <[email protected]> Date: Sun Aug 9 20:22:58 2026 -0700 fortran: [PR103474] Fix ICEs for the cobounds of a subobject of a coarray F2018:5.4.7(5) makes a subobject of a coarray a coarray with the same codimensions, unless it is reached through a cosubscript, an image selector, or an allocatable or pointer component selector. Querying the cobounds of such a subobject, as in LCOBOUND (X%A), reached three places that were not prepared for it, and a coarray whose declaration had already been rejected reached a fourth. PR fortran/103474 gcc/fortran/ChangeLog: * simplify.cc (simplify_cobound): Take the array spec from the base symbol, using its class data for a CLASS coarray, so that a subobject of a coarray finds the codimensions. Return NULL for a symbol already flagged as erroneous and in place of the two gcc_unreachable calls reached on invalid code. * resolve.cc (gfc_expression_rank): Track the reference carrying the codimensions and take the corank from it rather than from the last array reference. Clear it at an allocatable or pointer component selector, which ends the coarray. * trans-intrinsic.cc (strip_subobject_of_coarray): New function. Return a copy of the expression cut back to the reference carrying the codimensions. (conv_intrinsic_cobound, trans_this_image, trans_image_index): Use it, so that the descriptor queried for the cobounds is that of the coarray and not that of a component of it. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_52.f90: New test. * gfortran.dg/coarray/cobounds_subobject_1.f90: New test.
