Movatterモバイル変換


[0]ホーム

URL:


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

2025-12-20


1119. Missing case in description of member access ambiguity

Section:7.6.1.5  [expr.ref]    Status:C++11    Submitter:US    Date:2010-08-02

[Voted into the WP at the November, 2010 meeting.]

N3092 comment US 32

According to 7.6.1.5 [expr.ref] paragraph 5,

IfE2 is a non-static data member or a non-staticmember function, the program is ill-formed if the class ofwhichE2 is directly a member is an ambiguous base(6.5.2 [class.member.lookup]) of the naming class(11.8.3 [class.access.base]) ofE2.

This does not cover the following case:

    struct A { int i; };    struct B: A { };    struct C: A, B { };    void f(C* p) {      p->A::i; // Should be ambiguous    }

Notes (August, 2010):

The example in the FCD National Body comment is incorrect: it ismissing theA:: in the next-to-last line.

The ambiguity actually is covered in the Standard but in anunexpected location: 11.8.3 [class.access.base] paragraph 6:

If a class member access operator, including an implicit“this->,” is used to access anon-static data member or non-static member function, thereference is ill-formed if the left operand (considered as apointer in the “.” operator case)cannot be implicitly converted to a pointer to the namingclass of the right operand.

An explanatory note, including a cross-reference to11.8.3 [class.access.base], should be added to7.6.1.5 [expr.ref] paragraph 6.

Proposed resolution (September, 2010):

Change 7.6.1.5 [expr.ref] paragraph 5 as follows:

IfE2 is a non-static data member or a non-static memberfunction, the program is ill-formed if the class of whichE2is directly a member is an ambiguous base (6.5.2 [class.member.lookup])of the naming class (11.8.3 [class.access.base]) ofE2.[Note: The program is also ill-formed if thenaming class is an ambiguous base of the class type of the objectexpression; see 11.8.3 [class.access.base]. —endnote]



[8]ページ先頭

©2009-2026 Movatter.jp