https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126668
Bug ID: 126668
Summary: converted pointer to data member unusable as template
argument
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ivan.lazaric.gcc at gmail dot com
Target Milestone: ---
```cpp
struct A { int a; };
struct B : A {};
template<auto> using T = int;
constexpr auto p1 = &A::a;
constexpr auto p2 = static_cast<int B::*>(p1);
constexpr auto p3 = static_cast<int A::*>(p2);
static_assert(p1 == p3);
using X = T<p1>;
using Y = T<p2>; // error
using Z = T<p3>; // error
```
Compiler output:
```
<source>:13:15: error: '0' is not a valid template argument for type 'int B::*'
13 | using Y = T<p2>; // error
| ^
<source>:13:15: note: it must be a pointer-to-member of the form '&X::Y'
<source>:14:15: error: '0' is not a valid template argument for type 'int A::*'
14 | using Z = T<p3>; // error
| ^
<source>:14:15: note: it must be a pointer-to-member of the form '&X::Y'
```
https://godbolt.org/z/d549WEh1f