Skip to content
Snippets Groups Projects
user avatar
Patrick Palka authored
On Tue, 9 Jan 2024, Jason Merrill wrote:
> On 1/5/24 15:01, Patrick Palka wrote[1]:
> > Here during default template argument substitution we wrongly consider
> > the (substituted) default arguments v and vt<int> as value-dependent[1]
> > 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, which lets us accept both
> > testcases by sidestepping the value_dependent_expression_p issue
> > altogether.
>
> Hmm, maybe instead of substituting and asking if it's dependent, we should
> specifically look for undeduced parameters.

This patch implements this refinement, which incidentally fixes PR101463
just as well.

[1]: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/641957.html



	PR c++/101463

gcc/cp/ChangeLog:

	* pt.cc (type_unification_real): Directly look for undeduced
	parameters in the default argument instead of doing a trial
	substitution.

gcc/testsuite/ChangeLog:

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

Reviewed-by: default avatarJason Merrill <jason@redhat.com>
5348e3cb
History
Name Last commit Last update