From 9329344a6d81a6a5e3bd171167ebc7b158bb44f4 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Wed, 22 Sep 2021 11:16:53 -0400 Subject: c++: concept-ids and value-dependence [PR102412] The problem here is that uses_template_parms returns true for all concept-ids (even those with non-dependent arguments), so when a concept-id is used as a default template argument then during deduction the default argument is considered dependent even after substituting into it, which leads to deduction failure (from type_unification_real). This patch fixes this by implementing the resolution of CWG 2446 which says a concept-id is dependent only if its arguments are. DR 2446 PR c++/102412 gcc/cp/ChangeLog: * constexpr.c (cxx_eval_constant_expression) : Check value_dependent_expression_p instead of processing_template_decl. * pt.c (value_dependent_expression_p) : Return true only if any_dependent_template_arguments_p. (instantiation_dependent_r) : Remove this case. : Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-nondep2.C: New test. * g++.dg/cpp2a/concepts-nondep3.C: New test. --- gcc/cp/constexpr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/constexpr.c') diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 8a5dd06..18d9d11 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -7117,7 +7117,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, break; } - if (!processing_template_decl + if (!value_dependent_expression_p (t) && !uid_sensitive_constexpr_evaluation_p ()) r = evaluate_concept_check (t); else -- cgit v1.1