[gnu.g++.bug] stupid warning

eppstein@garfield (David Eppstein) (05/07/89)

G++ warns me when a derived class has a member function that shadows
(with different type) a member of an ancestor class.  So far so good.
But it warns even when the shadowed member is private, and therefore
totally invisible to the derived class!
If it's invisible, why should I care that it has the same name?

Replies by mail please, I don't read gnu.g++.bug.

    ------------ sample code illustrating the bug ------------
class foo {
   int state;
 public:
    foo() { state = 1; }
    int baz() { return state; }
};
class bar : public foo { public: int state() { return baz(); } };

    ------------ output from g++ run on the sample ------------
g++ version 1.32.0
 /usr/local/gnu/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix test.c /tmp/cc026501.cpp
GNU CPP version 1.33
 /usr/local/gnu/lib/gcc-c++ /tmp/cc026501.cpp -quiet -dumpbase test.c -version -o /tmp/cc026501.s
GNU C++ version 1.32.0 (vax) compiled by GNU C version 1.33.
In function bar::state ():
test.c:7: warning: shadowing member `state' with member function
 as /tmp/cc026501.s -o test.o
 /usr/local/gnu/lib/gcc-ld++ -C /usr/local/gnu/lib/crt0+.o test.o -lg++ /usr/local/gnu/lib/gcc-gnulib -lc
Undefined symbols:
 _main

-- 
David Eppstein  eppstein@garfield.cs.columbia.edu  Columbia U. Computer Science