-2

I asked question about Multiple inheritance to avoid ambiguity by using scope resolution . Where my answer explained B::i is well-formed.

But, I found in c++ open-std document, Where I2::i is ill-formed.

struct D2: I1, I2 {
        void f() {
            I2::i = 0;    // ill-formed per proposal
        }
    };

So, Is my answer true?

msc
  • 33,420
  • 29
  • 119
  • 214

2 Answers2

4

You're not reading that properly. Look at the text that follows:

In my proposed wording, the class of "this" can't be converted to "B" (the qualifier is ignored), so the access is ill-formed. Oops.

I think the following is a correct formulation, so the proposed resolution we discuss in Sydney should contain the following paragraph instead of the one in N1543:

    If E2 is a nonstatic data member or a non-static member function, the program is ill-formed if the naming class (11.2) of E2 cannot be unambiguously converted (10.2) to the class of which E2 is directly a member.

The example showed a problem with the earlier proposed wording. It's an example that was given specifically because it's supposed to be valid, to prevent it being made invalid.

Community
  • 1
  • 1
3

The linked issue points out that a particular proposal makes the quoted code ill-formed. It appears to be saying that this is an argument that the exact form of that particular proposal is flawed, and the intent was to improve the proposal so that it no longer breaks that code. In the final version of the proposal N1626, this example does not appear. The merging of N1626 into the C++11 standard appears to have resolved this issue (I don't know why it isn't marked as resolved on that page). So no, the quoted code is not going to become ill-formed.

Brian Bi
  • 111,498
  • 10
  • 176
  • 312