Open
Description
template<typename T, int I = 0>
struct A {};
template<typename T, int I = 0>
using B = A<T, I>;
template<template <typename> typename T>
void g() {}
void f() {
g<A>();
g<B>();
}
fails to compile on Clang 16 (using -frelaxed-template-template-args
) with the following error:
<source>:12:5: error: no matching function for call to 'g'
g<B>();
^~~~
<source>:8:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'T'
void g() {}
^
The same code compiles on Clang 15. Removing -frelaxed-template-template-args
makes that code fail in both Clang 15 and 16 and also complains about g<A>()
with the same error.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
llvmbot commentedon Jun 13, 2023
@llvm/issue-subscribers-clang-frontend
krobelus commentedon Jun 13, 2023
bisects to ef8feb6..f4ea3bd (using manyclangs)
probably introduced by f4ea3bd, cc @mizvekov
aThorp96 commentedon Oct 24, 2023
This appears to affect Apple's
clang
15 as well. Is this the right place for that report?mizvekov commentedon Apr 27, 2024
Note that this didn't work in clang-15 properly either: https://godbolt.org/z/GbcEvW1cM
Notice the previously incorrect deduction, which would produce a different instantiation, and so failing to diagnose the duplicate explicit instantiation.
mizvekov commentedon Apr 28, 2024
The latter issue, which I mentioned, of producing different instantiations is tracked by CWG1286, which is still unresolved, but we should probably implement provisional wording.
There is already an LLVM issue for it: #65843
The original issue, failure to deduce an alias template, I believe clang is correct to reject it.
See https://eel.is/c++draft/temp.deduct#type-8 and more specifically https://eel.is/c++draft/temp.deduct#type-8.2
An alias template is neither a class template nor a template template parameter.
And see also this note: https://eel.is/c++draft/temp.alias#note-1
cor3ntin commentedon Apr 30, 2024
@mizvekov
I agree with this reading. You might want to improve diagnostics in a separate PREdit: Actually, I'm not sure. What we are trying to deduce here is not the alias but its template arguments.
And there is wild divergence. It might be a bug in https://eel.is/c++draft/temp.deduct#type-8 @zygoloid @erichkeane
Edit2: not that much divergence https://godbolt.org/z/jc77frbMz
But this looks like CWG2037/CWG1286/etc