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 c++/100134] [modules] ICE when using a vector in a module
Date: Tue, 11 Oct 2022 19:03:05 +0000	[thread overview]
Message-ID: <bug-100134-4-lYSD5Q8iSW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100134-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:9736a42e1fb8df30d72cf28594d9046bf50200c1

commit r13-3236-g9736a42e1fb8df30d72cf28594d9046bf50200c1
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Oct 11 15:02:23 2022 -0400

    c++ modules: ICE with templated friend and std namespace [PR100134]

    The function depset::hash::add_binding_entity has an assert verifying
    that if a namespace contains an exported entity, then the namespace must
    have been opened in the module purview:

      if (data->hash->add_namespace_entities (decl, data->partitions))
        {
          /* It contains an exported thing, so it is exported.  */
          gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl));
          DECL_MODULE_EXPORT_P (decl) = true;
        }

    We're tripping over this assert in the below testcase because by
    instantiating and exporting std::A<int>, we in turn define and export the
    hidden friend std::f(A<int>) without ever having opened the enclosing
    namespace std within the module purview, and thus DECL_MODULE_PURVIEW_P
    for std is false.

    It's important that the enclosing namespace is std here: if we use
    a different namespace then the ICE disappears.  This probably has
    something to do with us predefining std via push_namespace from
    cxx_init_decl_processing (which makes it look like we've opened it
    within the TU), whereas with another namespace we would instead lazily
    create its NAMESPACE_DECL from add_imported_namespace.

    Since templated friend functions are special in that they give us a way
    to introduce a namespace-scope function without having to explicitly
    open the namespace, this patch proposes to fix this ICE by propagating
    DECL_MODULE_PURVIEW_P from the introduced function to the enclosing
    namespace during tsubst_friend_function.

            PR c++/100134

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_friend_function): Propagate DECL_MODULE_PURVIEW_P
            from the introduced namespace-scope function to the namespace.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/tpl-friend-8_a.H: New test.
            * g++.dg/modules/tpl-friend-8_b.C: New test.

  parent reply	other threads:[~2022-10-11 19:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-18  9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
2021-06-20  9:03 ` [Bug c++/100134] [modules] ICE when using a vector in a module ensadc at mailnesia dot com
2022-03-10 14:49 ` sandipan.mohanty at gmail dot com
2022-04-06  7:47 ` sandipan.mohanty at gmail dot com
2022-04-06  7:52 ` sandipan.mohanty at gmail dot com
2022-09-26 23:33 ` pinskia at gcc dot gnu.org
2022-09-26 23:34 ` johelegp at gmail dot com
2022-10-07 19:11 ` ppalka at gcc dot gnu.org
2022-10-11 19:03 ` cvs-commit at gcc dot gnu.org [this message]
2022-10-12 14:36 ` ppalka 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-100134-4-lYSD5Q8iSW@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).