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

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

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

commit r11-8520-gf1feb74046e0feb0596b93bbb822fae02940a90e
Author: Patrick Palka <ppa...@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)

Reply via email to