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++/56556] New: Wshadow warns for private members in base classes


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: unassigned@gcc.gnu.org
        ReportedBy: david@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.


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