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++/12060] New: Adding virtual functions changes access to data member of class.


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Adding virtual functions changes access to data member
                    of class.
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: duma at gorodok dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i586-mandrake-linux-gnu
  GCC host triplet: i586-mandrake-linux-gnu
GCC target triplet: i586-mandrake-linux-gnu

Access qualifier in declaring derived classes is 'protected'. 
Qualified access to access data member is used in the most derived class. 
Data member is declared protected. 
 
Adding virtual functions in class hierarchy leads to error:  
access to base class' member is forbidden. 
 
The following code demonstrate it: 
//removing all virtual functions makes it compilable 
class A 
{ 
protected: 
        int a; 
}; 
 
class B : protected A {}; 
 
class C : protected A 
{ 
//comment it out 
        virtual void f()=0; 
}; 
 
class D : protected B, protected C 
{ 
public: 
public: 
//comment it out  
        virtual void g()=0; 
}; 
 
class S : public D 
{ 
        int c; 
        void setc(){ c = B::a + C::a;} 
//comment it out 
        void g(){} 
        void f(){} 
};


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