https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47425

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:31f66a843429269ee9cdc6ce69ba3ff698773a35

commit r17-3155-g31f66a843429269ee9cdc6ce69ba3ff698773a35
Author: Jerry DeLisle <[email protected]>
Date:   Sat Aug 8 08:59:16 2026 -0700

    fortran: [PR47425] Array constructor fails with length type expr

    Two separate problems are fixed here. The original test case is fixed
    by the one-liner in trans-array.cc. Add check for INTEGER_CST. The
    remaining problem starts with parsing and not keeping track of charlens
    where some of the charlens are created and later left dangling. Code was
    added to keep track of these and remove them as needed.

            PR fortran/47425

    gcc/fortran/ChangeLog:

            * decl.cc (discard_pending_charlen): Use new helper
            function.
            (discard_pending_charlens): Likewise.
            (build_struct): Likewise.
            * gfortran.h (struct gfc_charlen): Add a namespace
            pointer to track char len for undo.
            (struct gfc_undo_change_set): Add cls
            pointer to track charlens created during parsing.
            (struct gfc_undo_change_set): Add vec<gfc_charlen *> cls.
            (gfc_remove_saved_charlen): Declare new helper function.
            * parse.cc (accept_statement): Adjust comment.
            * symbol.cc (gfc_merge_new_implicit): Use new helper function
            (free_undo_change_set_data): Release cls.
            (gfc_drop_last_undo_checkpoint): Splice cls into parent
            changeset.
            (gfc_restore_last_undo_checkpoint): Remove and free charlens
            tracked in cls.
            (gfc_commit_symbols): Truncate cls.
            (gfc_remove_saved_charlen): New function to remove
            previously saved char len.
            (gfc_free_namespace): Remove charlens from undo before freeing
            to prevent double-free.
            (gfc_enforce_clean_symbol_state): Clear cls instead of asserting
            empty; non-tentative callers leave charlens in cls.
            * trans-array.cc (trans_array_constructor): Add guard.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr47425-1.f90: New test.
            * gfortran.dg/pr47425-2.f90: New test.
  • [Bug fortran/47425] Array const... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to