[PATCH] fortran: [PR125760] Fix ICE in SELECT TYPE with array-section selector of a class array

Jerry DeLisle jvdelisle2@gmail.com
Sat Oct 10 19:57:45 GMT 2026


See attached patch. SELECT TYPE with an array section of a CLASS array
as the selector, e.g. select type (a => ptr(2:4)), ICEs in
tree_operand_check. When copying _len, trans_associate_var assumes
target_expr is a COMPONENT_REF to _data and strips it with
TREE_OPERAND, but a section gives a bare descriptor. The patch strips
only a COMPONENT_REF and otherwise gets the class container from the
selector expression with gfc_get_class_from_gfc_expr.

The fix is in trans_associate_var in trans-stmt.cc; the rest is the new
test. The bug was found with the Fujitsu compiler test suite; the test
is new.

Regression tested on x86_64.

OK for mainline?

Regards,

Jerry

---

fortran: [PR125760] Fix ICE in SELECT TYPE with array-section selector of a class array

In trans_associate_var, get the class container for the _len copy
from the selector expression when target_expr is not a _data
COMPONENT_REF.

Assisted-by: Claude Opus 5.5

	PR fortran/125760

gcc/fortran/ChangeLog:

	* trans-stmt.cc (trans_associate_var): Use
	gfc_get_class_from_gfc_expr when target_expr is not a
	COMPONENT_REF.

gcc/testsuite/ChangeLog:

	* gfortran.dg/select_type_52.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR125760-select-type-class-array-section-ice.patch
Type: text/x-patch
Size: 3446 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20261010/6b52e5ad/attachment-0001.bin>


More information about the Gcc-patches mailing list