The following program should return 1 when executed:

struct A {
  virtual int f() {return 1;}
};

struct B : virtual A {
  virtual int f() {return 0;}
};

struct C : B , virtual A {
  using A::f;
};

int
main () {
  C c;
  return c.f () + c.C::f ();
}

It actually returns 2.

The C++ standard section 10.3 shows the example which somewhat matches the code
above. The 'c.f()' is supposed to call 'B::f' and the 'c.C::f()' is supposed
to call 'A::f'. In fact, both call 'A::f'.


-- 
           Summary: using declaration misinterpreted in classes
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29136

Reply via email to