[Bug fortran/82721] [13/14/15/16 Regression] Error message with corrupted text, sometimes ICE
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 29 16:37:34 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82721
--- Comment #25 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:7103afbdd74ff57fb4cc226704b2acd89dc4e0d0
commit r13-10230-g7103afbdd74ff57fb4cc226704b2acd89dc4e0d0
Author: Christopher Albert <albert@tugraz.at>
Date: Tue Mar 10 18:17:32 2026 +0100
Fortran: Fix ICE after rejected CHARACTER duplicate declaration [PR82721]
When a CHARACTER declaration is rejected because the symbol already has
a different basic type, declaration parsing may already have created a
fresh gfc_charlen node for the rejected entity. reject_statement()
undoes symbol-table changes, but it does not roll back the namespace
charlen list, so the stale len(...) expression can survive and later be
resolved through dangling symtree pointers, causing corrupted
diagnostics or an ICE.
Fix this in build_sym by discarding only the unattached gfc_charlen
node created for the rejected declaration before it is ever attached to
any surviving symbol. Keep shared charlen nodes intact so other
invalid-code diagnostics still see the state they expect. Also add a
regression test that uses MALLOC_PERTURB_ to make the old crash
reproducible.
gcc/fortran/ChangeLog:
PR fortran/82721
* decl.cc (discard_pending_charlen): New helper.
(build_sym): Discard unattached CHARACTER length nodes when
gfc_add_type rejects the declaration.
gcc/testsuite/ChangeLog:
PR fortran/82721
* gfortran.dg/pr82721.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
(cherry picked from commit 5cfaad50af7dc25f6174044cdc05ebd56b6c4e3c)
More information about the Gcc-bugs
mailing list