[Bug fortran/106946] [13/14/15/16 Regression] ICE in resolve_component, at fortran/resolve.cc:14726
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 12 01:26:48 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106946
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:0d0fbb0a01e4e77e274e0ff9b54506a495a7bdef
commit r16-8021-g0d0fbb0a01e4e77e274e0ff9b54506a495a7bdef
Author: Christopher Albert <albert@tugraz.at>
Date: Tue Mar 10 17:32:32 2026 +0100
Fortran: Fix ICE on invalid CLASS component in derived type [PR106946]
When a CLASS component declaration inside a derived type has a syntax
error (for example, a missing comma), gfc_build_class_symbol creates a
CLASS container symbol outside the undo mechanism. Error recovery then
frees the referenced type but leaves the CLASS container orphaned with
dangling pointers, leading to an ICE during later resolution.
Fix this by removing CLASS components created during a failed data
declaration from the derived type component chain, deleting their
namespace symtree entries only when they are still present, releasing
the CLASS container symbol, and freeing the component itself. Also
expand the regression coverage to exercise allocatable and pointer CLASS
declarations, including a valid component followed by a bad one.
gcc/fortran/ChangeLog:
PR fortran/106946
* decl.cc (gfc_match_data_decl): Remove CLASS components added by a
failed declaration in a derived type, and guard symtree deletion.
* gfortran.h (gfc_free_component, gfc_delete_symtree): Declare.
* symbol.cc (gfc_free_component): New function.
(free_components): Use it.
(gfc_delete_symtree): Make non-static.
gcc/testsuite/ChangeLog:
PR fortran/106946
* gfortran.dg/pr106946.f90: Cover allocatable and pointer CLASS
declarations, including a valid component followed by a bad one.
Signed-off-by: Christopher Albert <albert@tugraz.at>
More information about the Gcc-bugs
mailing list