This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2705. Accessing ambiguous subobjects

Section:  [expr.ref]     Status: open     Submitter: Davis Herring     Date: 2023-02-11


  struct A {int i;};
  struct X : A {};
  struct Y : A {};
  struct S : X,Y {};

  void f(S &s) {++s.X::i;}

There is a rule that &s be able to "be implicitly converted to a pointer to the naming class of the right operand" (11.8.3 [class.access.base] paragraph 6), which correctly selects X here, but [expr.ref] bullet 6.2 merely says that

If E2 is a non-static data member [...], the expression designates the corresponding member subobject of the object designated by the first expression.

E2 (i.e. X::i) and Y::i equally denote A::i (since name lookup produces declarations), but there is no rule that indicates which A::i is selected as the "corresponding member subobject". (Note that s.X::A::i means the same as s.A::i and is ambiguous.)

Suggested resolution:

Change 11.8.3 [class.access.base] paragraph 6 to actually perform the conversion it requires, possibly moving it to [expr.ref] since it is not about access control; the definition of "naming class" in 11.8.3 [class.access.base] paragraph 5 would then need to be italicized.