The master branch has been updated by Jerry DeLisle <[email protected]>:
https://gcc.gnu.org/g:3461bb8b7148d0cfe1a1505768accef330e88743
commit r17-5521-g3461bb8b7148d0cfe1a1505768accef330e88743
On 10/23/26 12:11 PM, Jerry DeLisle wrote:
I have attached a patch for the subject PR. Mikael's comment in the PR prompted
me to look elsewhere. This fix turns out simple and obvious,
I plan to commit later today.
Regression tested on x86_64.
Regards,
Jerry
---
fortran: [PR125763] Fix ICE for character pointer initialized
to a substring
A character pointer initialized to a substring in its declaration, e.g.
character(len=:), pointer :: p => t(2:4)
ICE'd in gfc_get_symbol_decl because the substring's character length
was never set. gfc_resolve_expr did not resolve the substring length
when the first reference of the variable is the substring itself, as
for a scalar variable, so fixup_charlen gave the expression a charlen
with no length. Resolve the substring length in that case too.
With that change, the frontend temporary that create_var makes for a
deferred-length assignment such as a = a(m:n) gets an explicit LEN()
length but kept the deferred flag of the variable, which tripped an
assertion in gfc_trans_deferred_vars. Clear the deferred flag when the
temporary is given an explicit length.
PR fortran/125763
gcc/fortran/ChangeLog:
* frontend-passes.cc (create_var): Clear ts.deferred when the
temporary gets an explicit length from LEN().
* resolve.cc (gfc_resolve_expr): Resolve the substring length
also when the first reference is the substring.
gcc/testsuite/ChangeLog:
* gfortran.dg/char_pointer_substring_init.f90: New test.
---