Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inside a class body, pointers to members of the class are turned into ordinary pointers #374

Closed
languagelawyer opened this issue Jan 31, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@languagelawyer
Copy link

struct S;

struct T
{
  int S::* s_mptr;
  int T::* t_mptr;
  static int T::* static_mptr;

  template<int S::*> void f();
  template<int T::*> void f();
  
  template<int (S::*)()> void f();
  template<int (T::*)()> void f();
  
  struct N
  {
    int S::* s_mptr;
    int T::* t_mptr;
    int N::* n_mptr;
  };
  int N::* n_mptr;
};

int T::* T::static_mptr = 0;
template<int T::*>     void T::f() {}
template<int (T::*)()> void T::f() {}

is transformed into

struct S;

struct T
{
  int S::* s_mptr;
  int * t_mptr;
  static using MemberVarPtr_7 = int *;
  MemberVarPtr_7 static_mptr;
  template<int S::* >
  void f();
  template<int * >
  void f();
  template<int (S::*)() >
  void f();
  template<int (*)() >
  void f();
  struct N
  {
    int S::* s_mptr;
    int * t_mptr;
    int * n_mptr;
  };
  
  int N::* n_mptr;
};



using MemberVarPtr_23 = int T::*;
MemberVarPtr_23 static_mptr = 0;

template<int T::*>     void T::f() {}
template<int (T::*)()> void T::f() {}

All pointers to members of T (T::N) inside T (T::N) body became ordinary pointers to objects or functions. Out-of-line definitions are OK.

@andreasfertig andreasfertig added the bug Something isn't working label Feb 5, 2021
@andreasfertig
Copy link
Owner

Hello @languagelawyer,

thanks for reporting this issue. It looks like my brute-force approach of remove unwanted namespaces was too much. A fix is on its way.

Andreas

andreasfertig added a commit that referenced this issue Feb 5, 2021
Fixed #374: Do not remove namespace for member pointers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants