public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/107426] [12/13/14 Regression] ICE in gfc_compare_derived_types, at fortran/interface.cc:636
Date: Fri, 22 Mar 2024 13:33:00 +0000	[thread overview]
Message-ID: <bug-107426-4-glbAHX3Blj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107426-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mikael Morin <mikael@gcc.gnu.org>:

https://gcc.gnu.org/g:a44d7e8a52007c2d45217709ca02947c6600de87

commit r14-9619-ga44d7e8a52007c2d45217709ca02947c6600de87
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Thu Mar 21 17:27:54 2024 +0100

    fortran: Ignore use statements on error [PR107426]

    This fixes an access to freed memory on the testcase from the PR.
    The problem comes from an invalid subroutine statement in an interface,
    which is ignored and causes the following statements forming the procedure
    body to be rejected.  One of them use-associates the intrinsic
ISO_C_BINDING
    module, which imports new symbols in a namespace that is freed at the time
    the statement is rejected.  However, this creates dangling pointers as
    ISO_C_BINDING is special and its import creates a reference to the imported
    C_PTR symbol in the return type of the global intrinsic symbol for C_LOC
    (see the function create_intrinsic_function).

    This change saves and restores the list of use statements, so that rejected
    use statements are removed before they have a chance to be applied to the
    current namespace and create dangling pointers.

            PR fortran/107426

    gcc/fortran/ChangeLog:

            * gfortran.h (gfc_save_module_list, gfc_restore_old_module_list):
            New declarations.
            * module.cc (old_module_list_tail): New global variable.
            (gfc_save_module_list, gfc_restore_old_module_list): New functions.
            (gfc_use_modules): Set module_list and old_module_list_tail.
            * parse.cc (next_statement): Save module_list before doing any
work.
            (reject_statement): Restore module_list to its saved value.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr89943_3.f90: Update error pattern.
            * gfortran.dg/pr89943_4.f90: Likewise.
            * gfortran.dg/use_31.f90: New test.

  parent reply	other threads:[~2024-03-22 13:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 18:40 [Bug fortran/107426] New: [12/13 " gscfq@t-online.de
2022-10-26 19:42 ` [Bug fortran/107426] " anlauf at gcc dot gnu.org
2022-10-27  0:22 ` kargl at gcc dot gnu.org
2022-10-28 11:35 ` rguenth at gcc dot gnu.org
2023-03-12 12:31 ` mikael at gcc dot gnu.org
2023-03-12 16:45 ` mikael at gcc dot gnu.org
2023-03-12 16:47 ` mikael at gcc dot gnu.org
2023-03-12 17:31 ` mikael at gcc dot gnu.org
2023-05-08 12:25 ` [Bug fortran/107426] [12/13/14 " rguenth at gcc dot gnu.org
2024-03-22 13:33 ` cvs-commit at gcc dot gnu.org [this message]
2024-03-30  9:13 ` pault at gcc dot gnu.org
2024-03-30 10:28 ` mikael at gcc dot gnu.org
2024-03-31 14:25 ` cvs-commit at gcc dot gnu.org
2024-04-02 13:08 ` cvs-commit at gcc dot gnu.org
2024-04-02 13:11 ` cvs-commit at gcc dot gnu.org
2024-04-02 13:13 ` mikael at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107426-4-glbAHX3Blj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).