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

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

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

commit r10-7835-ga3a4f6be0c7ac1536c4d1def14217840b04dd488
Author: Patrick Palka <ppa...@redhat.com>
Date:   Mon Apr 20 18:34:00 2020 -0400

    c++: Recursive unification with packs and explicit targs [PR94628]

    This PR seems to be similar to PR c++/43382, except that the recursive call
to
    the variadic function with trailing return type in this testcase is
additionally
    given some explicit template arguments.

    In the first testcase below, when resolving the recursive call to 'select',
    fn_type_unification first substitutes in the call's explicit template
arguments
    before doing unification, and so during this substitution the template
argument
    pack for Args is incomplete.

    Since the pack is incomplete, the substitution of 'args...' in the trailing
    return type decltype(f(args...)) is handled by the unsubstituted_packs case
of
    tsubst_pack_expansion.  But the handling of this case happens _before_ we
reset
    local_specializations, and so the substitution ends up reusing the old
binding
    for 'args' from local_specializations rather than building a new one.

    This patch fixes this issue by setting up local_specializations sooner in
    tsubst_pack_expansion, before the handling of the unsubstituted_packs case.
    It also adds a new policy to local_specialization_stack so that we could
use the
    class here to conditionally replace local_specializations.

    gcc/cp/ChangeLog:

            PR c++/94628
            * cp-tree.h (lss_policy::lss_nop): New enumerator.
            * pt.c (local_specialization_stack::local_specialization_stack):
Handle
            an lss_nop policy.
            (local_specialization_stack::~local_specialization_stack):
Likewise.
            (tsubst_pack_expansion): Use a local_specialization_stack instead
of
            manually saving and restoring local_specializations.  Conditionally
            replace local_specializations sooner, before the handling of the
            unsubstituted_packs case.

    gcc/testsuite/ChangeLog:

            PR c++/94628
            * g++.dg/cpp0x/variadic179.C: New test.
            * g++.dg/cpp0x/variadic180.C: New test.

Reply via email to