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



             Bug #: 56556

           Summary: Wshadow warns for private members in base classes

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: da...@doublewise.net





The following code warns due to -Wshadow:



class Base {

private:

    int x;

};



class Derived : public Base {

    Derived(int x) {}

};



Perhaps we should consider not having this warn? In my particular case, I have

a Base class with a private member variable, a class Derived that derives from

Base, and a class EvenMoreDerived that derives from Derived. In a member

function of EvenMoreDerived, I am trying to use a variable with the same name

as the private member variable of Base.



The only situation I can think of where this could theoretically be useful is

if there is some kind of overload resolution issue, but due to derived classes

hiding member functions of base classes I don't imagine that would be an issue.

Reply via email to