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

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

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

commit r16-8485-gca20148d0b784ce52f83a33fc3abb2693a0d6a41
Author: Nathaniel Shead <[email protected]>
Date:   Mon Apr 6 00:34:33 2026 +1000

    c++/modules: Fix propagating noexcept for templates [PR124785]

    We triggered a checking assertion because when propagating deduced
    noexcept, we were updating the type of the existing TEMPLATE_DECL but
    not the type of its DECL_TEMPLATE_RESULT, violating assumptions made
    later on during modules streaming.

    But actually there was nothing to propagate here anyway, these
    declarations are identical, so this patch also fixes the condition for
    checking whether we need to propagate anything.  And so now I don't
    think there is ever a case we should have a noexcept-spec to propagate
    for a TEMPLATE_DECL, so add an assertion to validate this.

            PR c++/124785

    gcc/cp/ChangeLog:

            * module.cc (trees_in::is_matching_decl): Narrow condition for
            when noexcept propagation occurs; assert that we don't propagate
            noexcept-specs for TEMPLATE_DECLs.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/noexcept-5.h: New test.
            * g++.dg/modules/noexcept-5_a.C: New test.
            * g++.dg/modules/noexcept-5_b.C: New test.
            * g++.dg/modules/noexcept-5_c.C: New test.

    Signed-off-by: Nathaniel Shead <[email protected]>
    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to