This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/77725] New: An example from the standard regarding member lookup fails to compile


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77725

            Bug ID: 77725
           Summary: An example from the standard regarding member lookup
                    fails to compile
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ilaizi at microsoft dot com
  Target Milestone: ---

Example of valid code from the standard (10.2.7 Member name lookup
[class.member.lookup])

compiled with command: "g++ -std=c++11 main.cpp && ./a.out" on Linux

compiler version:
g++ (GCC) 6.1.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
===================================================================================
struct A { int x; };                    // S(x,A) = { { A::x }, { A } }
struct B { float x; };                  // S(x,B) = { { B::x }, { B } }
struct C: public A, public B { };       // S(x,C) = { invalid, { A in C, B in C
} }
struct D: public virtual C { };         // S(x,D) = S(x,C)
struct E: public virtual C { char x; }; // S(x,E) = { { E::x }, { E } }
struct F: public D, public E { };       // S(x,F) = S(x,E)

int main() 
{
   F f;
   f.x = 0; // OK, lookup finds E::x
}
===================================================================================
Error message:

main.cpp: In function 'int main()':
main.cpp:11:6: error: request for member 'x' is ambiguous
    f.x = 0; // OK, lookup finds E::x
      ^
main.cpp:2:18: note: candidates are: float B::x
 struct B { float x; };                  // S(x,B) = { { B::x }, { B } }
                  ^
main.cpp:1:16: note:                 int A::x
 struct A { int x; };                    // S(x,A) = { { A::x }, { A } }
                ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]