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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>:

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

commit r15-9217-gb8e8829cfb73d7aa009d387ab09bdbab221930d7
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Fri Apr 4 11:56:53 2025 +1100

    c++/modules: Fix divergence in streaming/non-streaming tree walks
[PR119608]

    Modules streaming walks decls multiple times, first as a non-streaming
    walk to find dependencies, and then later to actually emit the decls.
    The first walk needs to be done to note locations that will be emitted.

    In the PR we are getting a checking ICE because we are streaming a decl
    that we didn't initially walk when collecting dependencies, so the
    location isn't in the noted locations map.  This is because in decl_node
    we have a branch where a PARM_DECL that hasn't previously been
    referenced gets walked by value only if 'streaming_p ()' is true.

    The true root cause here is that the decltype(v) in the testcase refers
    to a different PARM_DECL from the one in the declaration that we're
    streaming; it's the PARM_DECL from the initial forward-declaration, that
    we're not streaming.  A proper fix would be to ensure that it gets
    remapped to the decl in the definition we're actually emitting, but for
    now this workaround fixes the bug (and any other bugs that might
    manifest similarly).

            PR c++/119608

    gcc/cp/ChangeLog:

            * module.cc (trees_out::decl_node): Maybe require by-value
            walking not just when streaming.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr119608_a.C: New test.
            * g++.dg/modules/pr119608_b.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to