Type of base class member is wrong

I can’t compile this C++ code by NVCC.

template <typename T>
class A {
public: 
 T x;
};

template <typename T>
class B : public A<T> {
public:
 char* f() {
    char* p = (char*)(&(A<T>::x));
    return p;
 }
};

int main() {
    B<int> b;
    b.f();
}

I have output the type of base class members (T = int)

  • clang 6.0.1: typeid(&(A<T>::x)).name() is Pi
  • gcc 8.1: typeid(&(A<T>::x)).name() is Pi
  • NVCC 12.1.0: typeid(&(A<T>::x)).name() is M1AIiEi

see also: Compiler Explorer