[Bug c++/101181] [11/12 Regression] ICE when using an alias template

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 13 14:03:49 GMT 2021


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

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

https://gcc.gnu.org/g:63566075309907ca807c1c6cef57bf19f4602825

commit r11-8734-g63566075309907ca807c1c6cef57bf19f4602825
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 9 10:20:25 2021 -0400

    c++: requires-expr with dependent extra args [PR101181]

    Here we're crashing ultimately because the mechanism for delaying
    substitution into a requires-expression (and constexpr if and pack
    expansions) doesn't expect to see dependent args.  But we end up
    capturing dependent args here during substitution into the default
    template argument as part of coerce_template_parms for the dependent
    specialization p<T>.

    This patch enables the commented out code in add_extra_args for handling
    this situation.  This isn't needed for pack expansions (as the
    accompanying comment points out), and it doesn't seem strictly necessary
    for constexpr if either, but for requires-expressions delaying even
    dependent substitution is important for ensuring we don't evaluate
    requirements out of order.

    It turns out we also need to make a copy of the arguments when capturing
    them so that coerce_template_parms doesn't later add to them and form an
    unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to
t).
    We also need to make tsubst_template_args handle missing template
    arguments, since the arguments we capture from coerce_template_parms
    and are incomplete at that point.

            PR c++/101181

    gcc/cp/ChangeLog:

            * constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
            add_extra_args.
            * cp-tree.h (add_extra_args): Add complain/in_decl parameters.
            * pt.c (build_extra_args): Make a copy of args.
            (add_extra_args): Add complain/in_decl parameters.  Enable the
            code for handling the case where the extra arguments are
            dependent.
            (tsubst_pack_expansion): Pass complain/in_decl to
            add_extra_args.
            (tsubst_template_args): Handle missing template arguments.
            (tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
            add_extra_args.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-requires26.C: New test.
            * g++.dg/cpp2a/lambda-uneval16.C: New test.

    (cherry picked from commit 2c699fd29829cd6115f78238dab7cab74f0a5009)


More information about the Gcc-bugs mailing list