================
@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
       S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+                                          TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+    auto *T = cast<TemplateTypeParmDecl>(A);
+    // FIXME: DefaultArgument can't represent a pack.
+    if (T->isParameterPack())
----------------
mizvekov wrote:

The test `foo` in 
`clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp` exercises 
this, but it doesn't involve any default arguments, so any effects are 
incidental / harmless.

I have actually just come up with a relevant test case that shows something 
interesting that I wasn't aware before, this could possibly be new info for the 
core issue.

https://godbolt.org/z/rnbzhnqG7

This shows a change of behavior introduced by P05522, only instead of 
introducing ambiguity, it causes different candidates to be picked. Also 
affects GCC.

---

Regarding the FIXME:

So the (Type | NonType | Template) template parameter declarations store the 
default argument for themselves. They have a `setDefaultArgument` method for 
setting that. While for template template parameter declarations the 
`setDefaultArgument` takes a `TemplateArgument`, and that means it can use any 
kind of TemplateArgument as a default argument, including packs.

The same is not true for (Type | NonType) template parameter declarations, 
their `setDefaultArgument` only takes a (Type / Expression), which means a pack 
can't be passed.

This is done presumably to save space in those declarations, while a Type and 
an Expression are a single pointer, a `TemplateArgument` is considerably 
larger, and you would need at least a pointer and an integer to represent a 
pack.

To 'fix' this FIXME, we would have to change that, and allow those declarations 
to be larger in at least some circumstances.

https://github.com/llvm/llvm-project/pull/89807
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to