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

--- Comment #1 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:bebd8e9da838c51a7f911985083d5a2b2498a23a

commit r12-2309-gbebd8e9da838c51a7f911985083d5a2b2498a23a
Author: Patrick Palka <ppa...@redhat.com>
Date:   Wed Jul 14 15:37:30 2021 -0400

    c++: CTAD and forwarding references [PR88252]

    Here during CTAD we're incorrectly treating T&& as a forwarding
    reference even though T is a template parameter of the class template.

    This happens because the template parameter T in the out-of-line
    definition of the constructor doesn't have the flag
    TEMPLATE_TYPE_PARM_FOR_CLASS set, and during duplicate_decls the
    the redeclaration (which is in terms of this unflagged T) prevails.
    To fix this, we could perhaps be more consistent about setting the flag,
    but it appears we don't really need this flag to make the determination.

    Since the template parameters of an synthesized guide consist of the
    template parameters of the class template followed by those of the
    constructor (if any), it should suffice to look at the index of the
    template parameter to determine whether it comes from the class
    template or the constructor (template).  This patch replaces the
    TEMPLATE_TYPE_PARM_FOR_CLASS flag with this approach.

            PR c++/88252

    gcc/cp/ChangeLog:

            * cp-tree.h (TEMPLATE_TYPE_PARM_FOR_CLASS): Remove.
            * pt.c (push_template_decl): Remove TEMPLATE_TYPE_PARM_FOR_CLASS
            handling.
            (redeclare_class_template): Likewise.
            (forwarding_reference_p): Define.
            (maybe_adjust_types_for_deduction): Use it instead.  Add 'tparms'
            parameter.
            (unify_one_argument): Pass tparms to
            maybe_adjust_types_for_deduction.
            (try_one_overload): Likewise.
            (unify): Likewise.
            (rewrite_template_parm): Remove TEMPLATE_TYPE_PARM_FOR_CLASS
            handling.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/class-deduction96.C: New test.

Reply via email to