This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-07-24


2244. Base class access in aggregate initialization

Section: 11.8.5  [class.protected]     Status: open     Submitter: Richard Smith     Date: 2016-03-08

The rules in 11.8.5 [class.protected] assume an object expression, perhaps implicit, that can be used to determine whether access to protected members is permitted or not. It is not clear how that applies to aggregates and constructors. For example:

  struct A {
  protected:
    A();
  };
  struct B : A {
    friend B f();
    friend B g();
    friend B h();
  };
  B f() { return {}; }     // ok? 
  B g() { return {{}}; }   // ok? 
  B h() { return {A{}}; }  // ok?

Notes from the December, 2016 teleconference:

The consensus favored accepting f and g while rejecting h.

Notes from the March, 2018 meeting:

CWG affirmed the earlier direction and felt that there should be an implicit object expression assumed for these cases.