https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113272

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Ok, this behavior is interesting:
```
int g = 0;
int g1 = 0;
template <auto *a>
struct A {
  void f() { g++; }
};

template < const auto * a>
struct A<a>{
  void f(){ g1++; }
};

int x = 0;
const int x1 = 0;
int main()
{
        {
          int t = 0;
          A<&x> a;
          t++;
          a.f();
          if (g != t)
            return 1;
        }
        int t = 0;
        if (0){
          A<(const int *)&x> a1;
          a1.f();
          t++;
          if (g1 != t)
            return 1;
        }
        {
          A<&x1> a1;
          a1.f();
          t++;
          if (g1 != t)
            return 1;
        }
        return 0;
}
```

The above passes like expected but if we enable the case for `A<(const int
*)&x>`, we get a failure in that g is incremented and not g1.

Note MSVC has the same behavior for the above testcase. Though clang rejects it
with an error:
```
<source>:9:8: error: class template partial specialization is not more
specialized than the primary template [-Winvalid-partial-specialization]
    9 | struct A<a>{
      |        ^
<source>:4:8: note: template is declared here
    4 | struct A {
      |        ^
```

Which I find even more interesting ...

Reply via email to