[clang] [clang] Fix partial specialization matching for NTTPs of placeholder type (PR #225239)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 01:28:27 PDT 2026
ojhunt wrote:
I was trying to understand what that same type was doing vs qualifiers and found this weirdness with partial specialization: https://compiler-explorer.com/z/cnvG13EvW
Basically when not doing partial specialization we don't match `const int*` to `int*`, but with partial specialization we do. Rejecting the match in both cases seems like it should be correct, but gcc accepts in both cases.
This PR doesn't introduce the behavior, but if it is fixing other issues around matching maybe it should fix this as well?
```cpp
int bar;
template <auto> struct Foo{
static constexpr int wibble = 0;
};
template <> struct Foo<&bar>{
static constexpr int wibble = 1;
};
template <class, auto> struct Bar {
static constexpr int wibble = 0;
};
template <class T> struct Bar<T, &bar> {
static constexpr int wibble = 1;
};
static_assert(Foo<&bar>::wibble == 1);
static_assert(Bar<void, &bar>::wibble == 1);
static_assert(Foo<(const int*)&bar>::wibble == 0);
static_assert(Bar<void, (const int*)&bar>::wibble == 0);
```
https://github.com/llvm/llvm-project/pull/225239
More information about the cfe-commits
mailing list