Ideas for member access

Hi,

It seems that, after templates, the only big C++ feature that's far from
complete is member access checking. So I'd like to know if anyone has
already thought about this and has some design ideas.

Sebastian

My only thought about member access checking is that we can safely ignore it for a quite a while longer, if we want to, since a well-formed C++03 program can still compile even if we don't do any access checking. Friends, on the other hand, have an impact on name lookup, so we can't ignore friend declarations as long.

That said, I think part of the design for access checking is going to need the ability to either store a list of access checks that still need to be performed, or to be able to walk over an AST and perform access checking later. This is required for, e.g., out-of-line member definitions:

   class X {
     typedef int type;

   public:
     type f();
   };

   X::type X::f() { // delay access checking of X::type until we know that we're defining a member function within 'X'
   }

  - Doug

Douglas Gregor wrote:

It seems that, after templates, the only big C++ feature that's far from
complete is member access checking. So I'd like to know if anyone has
already thought about this and has some design ideas.

My only thought about member access checking is that we can safely
ignore it for a quite a while longer, if we want to, since a
well-formed C++03 program can still compile even if we don't do any
access checking.

True, but I need something to do. I don't want to work on templates,
since too many people working on the same thing with as little
coordination as we have cannot end well.

That said, I think part of the design for access checking is going to
need the ability to either store a list of access checks that still
need to be performed, or to be able to walk over an AST and perform
access checking later. This is required for, e.g., out-of-line member
definitions:

  class X {
    typedef int type;

  public:
    type f();
  };

  X::type X::f() { // delay access checking of X::type until we know
that we're defining a member function within 'X'
  }

Good point. This makes the most trivial way of implementing this impossible.

On the other hand, is there any place we need to delay checking other
than the typename in a declspec and the name of a declarator?

Sebastian

Douglas Gregor wrote:

It seems that, after templates, the only big C++ feature that's far from
complete is member access checking. So I'd like to know if anyone has
already thought about this and has some design ideas.

My only thought about member access checking is that we can safely
ignore it for a quite a while longer, if we want to, since a
well-formed C++03 program can still compile even if we don't do any
access checking.

True, but I need something to do.

Oh, well, in *that* case... :slight_smile:

I have a mental checklist of easily-separable features and semantics that need to be implemented. If it would be helpful, I could augment the C++ status page with a "C++ suggested TODO list" of such tasks.

That said, I think part of the design for access checking is going to
need the ability to either store a list of access checks that still
need to be performed, or to be able to walk over an AST and perform
access checking later. This is required for, e.g., out-of-line member
definitions:

class X {
   typedef int type;

public:
   type f();
};

X::type X::f() { // delay access checking of X::type until we know
that we're defining a member function within 'X'
}

Good point. This makes the most trivial way of implementing this impossible.

On the other hand, is there any place we need to delay checking other
than the typename in a declspec and the name of a declarator?

IIRC, we also need to delay access checking within templates, even when name lookup finds something within a non-dependent type or non-type-dependent expression. So this kind of delayed-checking mechanism would have to be somewhat general (or we'd have to ignore all access control within templates, which is also possible).

   - Doug

Douglas Gregor wrote:

Douglas Gregor wrote:

It seems that, after templates, the only big C++ feature that's far
from
complete is member access checking. So I'd like to know if anyone has
already thought about this and has some design ideas.

My only thought about member access checking is that we can safely
ignore it for a quite a while longer, if we want to, since a
well-formed C++03 program can still compile even if we don't do any
access checking.

True, but I need something to do.

Oh, well, in *that* case... :slight_smile:

I have a mental checklist of easily-separable features and semantics
that need to be implemented. If it would be helpful, I could augment
the C++ status page with a "C++ suggested TODO list" of such tasks.

That would be nice indeed.

Sebastian

The C++ status page would be a natural place for it!

-Chris