Issue |
147497
|
Summary |
Clang 20+ dependent type,value Template-Template resolution differs from GCC,MSVC,Clang10-19
|
Labels |
clang
|
Assignees |
|
Reporter |
rainerzufalldererste
|
The following C++-20 code produces different (seemingly incorrect) template resolution between Clang 20 and GCC,MSVC,Clang10-19:
```c++
#include <stdio.h>
template <typename T, auto value>
struct different_type_value_templ
{
};
template <typename T, T value>
struct same_type_value_templ
{
};
template <typename... TArgs>
struct resolve;
template <typename T>
void resolve_fallback()
{
puts("called with 'T' (fallback)");
}
template <template <typename T1, auto V2> typename T, typename T1, auto V2>
struct resolve<T<T1, V2>>
{
static void handle()
{
puts("called with 'T<T1, V2>'");
}
};
template <typename T>
concept can_handle_type_resolve = requires () {
resolve<T>::handle();
};
template <typename T>
void do_resolve()
{
if constexpr (can_handle_type_resolve<T>)
resolve<T>::handle();
else
resolve_fallback<T>();
}
int main()
{
// consistent:
do_resolve<different_type_value_templ<int, 1>>();
do_resolve<different_type_value_templ<bool, false>>();
// inconsistent:
do_resolve<same_type_value_templ<int, 1>>();
do_resolve<same_type_value_templ<bool, false>>();
}
```
Should seemingly produce (as does MSVC, GCC, Clang 10-19.1)
```
called with 'T<T1, V2>'
called with 'T<T1, V2>'
called with 'T<T1, V2>'
called with 'T<T1, V2>'
```
but produces the following on clang 20.1 (w/ `-std=c++20`)
```
called with 'T<T1, V2>'
called with 'T<T1, V2>'
called with 'T' (fallback)
called with 'T' (fallback)
```
See: https://godbolt.org/z/o445cKv4c
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs