[Bug c++/100138] ICE with constructor constrained (C++20 Concepts) by parameter pack length

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jul 16 22:49:22 GMT 2021


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

--- 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:2e63d08cb9bc001232734eed32e4bc3814a279a9

commit r11-8761-g2e63d08cb9bc001232734eed32e4bc3814a279a9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon May 10 22:33:04 2021 -0400

    c++: fn parm pack expansion inside constraint [PR100138]

    This PR is about CTAD but the underlying problems are more general;
    CTAD is a good trigger for them because of the necessary substitution
    into constraints that deduction guide generation entails.

    In the testcase below, when generating the implicit deduction guide for
    the constrained constructor template for A, we substitute the generic
    flattening map 'tsubst_args' into the constructor's constraints.  During
    this substitution, tsubst_pack_expansion returns a rebuilt pack
    expansion for sizeof...(xs), but doesn't carry over the
    PACK_EXPANSION_LOCAL_P (and PACK_EXPANSION_SIZEOF_P) flag from the
    original tree to the rebuilt one.  The flag is otherwise unset on the
    original tree but gets set for the rebuilt tree from make_pack_expansion
    since at_function_scope_p() is true (we're inside main).  This leads to
    a crash during satisfaction when substituting into the pack expansion
    because we don't have local_specializations set up (and it'd be set up
    for us if PACK_EXPANSION_LOCAL_P is unset)

    Similarly, tsubst_constraint needs to set cp_unevaluated so that the
    substitution performed therein doesn't rely on local_specializations.
    This avoids a crash during CTAD for C below.

    gcc/cp/ChangeLog:

            PR c++/100138
            * constraint.cc (tsubst_constraint): Set up cp_unevaluated.
            (satisfy_atom): Set up iloc_sentinel before calling
            cxx_constant_value.
            * pt.c (tsubst_pack_expansion): When returning a rebuilt pack
            expansion, carry over PACK_EXPANSION_LOCAL_P and
            PACK_EXPANSION_SIZEOF_P from the original pack expansion.

    gcc/testsuite/ChangeLog:

            PR c++/100138
            * g++.dg/cpp2a/concepts-ctad4.C: New test.

    (cherry picked from commit e7a9f085ffd34b0d7bc4b803c182b41494f609aa)


More information about the Gcc-bugs mailing list