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

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

https://gcc.gnu.org/g:124f2f62e01c6f110279608ad09e0f1d378e4899

commit r14-10890-g124f2f62e01c6f110279608ad09e0f1d378e4899
Author: Patrick Palka <ppa...@redhat.com>
Date:   Tue Nov 5 15:18:26 2024 -0500

    c++: reference variable as default targ [PR101463]

    Here during default template argument substitution we wrongly consider
    the (substituted) default arguments v and vt<int> as value-dependent
    which ultimately leads to deduction failure for the calls.

    The bogus value_dependent_expression_p result aside, I noticed
    type_unification_real during default targ substitution keeps track of
    whether all previous targs are known and non-dependent, as is the case
    for these calls.  And in such cases it should be safe to avoid checking
    dependence of the substituted default targ and just assume it's not.
    This patch implements this optimization for GCC 14, which lets us accept
    both testcases by sidestepping the value_dependent_expression_p issue
    altogether.  (Note that for GCC 15 we fixed this differently, see
    r15-3038-g5348e3cb9bc99d.)

            PR c++/101463

    gcc/cp/ChangeLog:

            * pt.cc (type_unification_real): Avoid checking dependence of
            a substituted default template argument if we can assume it's
            non-dependent.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/nontype6.C: New test.
            * g++.dg/cpp1z/nontype6a.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to