[Bug c++/100102] [9/10/11/12 Regression] ICE in tsubst, at cp/pt.c:15310

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 7 22:54:14 GMT 2021


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

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

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

commit r10-9895-gfc930b3010bd0de899a3da3209eab20664ddb703
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jun 4 13:46:53 2021 -0400

    c++: tsubst_function_decl and excess arg levels [PR100102]

    Here, when instantiating the dependent alias template
    duration::__is_harmonic with args={{T,U},{int}}, we find ourselves
    substituting the function decl _S_gcd.  Since we have more arg levels
    than _S_gcd has parm levels, an old special case in tsubst_function_decl
    causes us to unwantedly reduce args to its innermost level, yielding
    args={int}, which leads to a nonsensical substitution into the decl
    context and eventually a crash.

    The comment for this special case refers to three examples for which we
    ought to see more arg levels than parm levels here, but none of the
    examples actually demonstrate this.  In the first example, when
    defining S<int>::f(U) parms_depth is 2 and args_depth is 1, and
    later when instantiating say S<int>::f<char> both depths are 2.  In the
    second example, when substituting the template friend declaration
    parms_depth is 2 and args_depth is 1, and later when instantiating f
    both depths are 1.  Finally, the third example is invalid since we can't
    specialize a member template of an unspecialized class template like
    that.

    Given that this reduction code seems no longer relevant for its
    documented purpose and that it causes problems as in the PR, this patch
    just removes it.  Note that as far as bootstrap/regtest is concerned,
    this code is dead; the below two tests would be the first to reach it.

            PR c++/100102

    gcc/cp/ChangeLog:

            * pt.c (tsubst_function_decl): Remove old code for reducing
            args when it has excess levels.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-72.C: New test.
            * g++.dg/cpp0x/alias-decl-72a.C: New test.

    (cherry picked from commit 5357ab75dedef403b0eebf9277d61d1cbeb5898f)


More information about the Gcc-bugs mailing list