[PATCH] PR125529 ICE in DO CONCURRENT with DEFAULT(NONE) inside, ASSOCIATE

Jerry D jvdelisle2@gmail.com
Tue Jun 2 01:23:54 GMT 2026


This one is straightforward.

See attached.

Regression tested on x86_64.

OK for mainline? and then backport to 16.

Regards,

Jerry

---
fortran: ICE in DO CONCURRENT with DEFAULT(NONE) inside ASSOCIATE

Two bugs in check_default_none_expr caused a segfault when a DO CONCURRENT
with inline type-spec iterators (e.g. "integer :: i = 1:10") contained an
ASSOCIATE construct.

Bug 1: sym->ns->code was used to locate the ext.concur.forall_iterator
list.  When a symbol's namespace is an ASSOCIATE body, sym->ns->code is an
EXEC_BLOCK node, not the DO CONCURRENT node; reading ext.concur from it
interprets the wrong union member and yields a garbage pointer.  Fix: use
d->code instead, the DO CONCURRENT gfc_code node passed through the walker's
data parameter, which is always the correct node.

Bug 2: inline type-spec iterators are shadow iterators, stored internally
with a leading underscore prepended to the name.  The comparison of the
iterator's symtree name against the user-visible sym->name must skip that
underscore by advancing iter_name one character when iter->shadow is set.

PR fortran/125529

Assisted by: Claude Sonnet 4.6

gcc/fortran/ChangeLog:

	PR fortran/125529
	* resolve.cc (check_default_none_expr): Use d->code instead of
	sym->ns->code to locate the DO CONCURRENT forall_iterator list,
	avoiding a wrong-union-member read when the symbol's namespace is
	an ASSOCIATE body.  Skip leading underscore when comparing iterator
	names for shadow iterators.

gcc/testsuite/ChangeLog:

	PR fortran/125529
	* gfortran.dg/do_concurrent_assoc_default_none.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR125529-do-concurrent-default-none.patch
Type: text/x-patch
Size: 5067 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20260601/730217a3/attachment.bin>


More information about the Fortran mailing list