[Bug c++/124794] [reflection] ICE on member function template splicing

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124794

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Patrick Palka
<[email protected]>:

https://gcc.gnu.org/g:6068870174e6cd102e5c0e6c3df9ce58caa4b47b

commit r16-9527-g6068870174e6cd102e5c0e6c3df9ce58caa4b47b
Author: feedable <[email protected]>
Date:   Wed Jun 3 08:40:53 2026 -0400

    c++/reflection: member function template splicing [PR124794]

    cp_parser_splice_expression is stripping BASELINKs before resolving the
    expr; checks if the result is a BASELINK after that (by which point it
never
    is).  To fix it, stop stripping the BASELINK, add handling to
    check_splice_expr instead.

    In cp_parser_splice_specifier, the additional template param parsing fails
    to detect that the reflection is a template if it's wrapped in a BASELINKs,
    and decides not to parse the splice-specialization-specifier if the
    'template' keyword is missing. Grab the data from the reflection instead.

    During template instantiation, we blindly substitute the template part of a
    TEMPLATE_ID_EXPR, even if it's a SPLICE_EXPR. This, in turn, substitutes
the
    SPLICE_EXPR as-if it had no template arguments and finishes up the
    expression, which interferes with later processing by TEMPLATE_ID_EXPR.  To
    fix, we defer such TEMPLATE_ID_EXPRs to tsubst_splice_expr, which itself
    performs the substitution of a TEMPLATE_ID_EXPR and finishes up the
    expression.

    check_splice_expr now also accepts TEMPLATE_ID_EXPRs in tsubst_splice_expr;
    this is uniform with cp_parser_splice_expression, and required in order to
    handle `template[:dep:]<>` where `dep` does not reflect a template.

            PR c++/124794
            PR c++/125069

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_splice_specifier): Do not strip BASELINKs.
            (cp_parser_splice_expression): Add parsing for member function
            template specializations without the "template" keyword.
            * pt.cc (tsubst_splice_expr): Handle TEMPLATE_ID_EXPR where the
            template part is a SPLICE_EXPR.
            (tsubst_expr): Defer to tsubst_splice_expr when the template part
of
            TEMPLATE_ID_EXPR is a SPLICE_EXPR.
            * reflect.cc (check_splice_expr): Add handling for BASELINKs.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/member19.C: Enable tests.
            * g++.dg/reflect/splice15.C: New test.
            * g++.dg/reflect/splice16.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>
    (cherry picked from commit 719156070f5f5f9070a4d9b736c238b5d028f719)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.