🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1951

stupid warning

#1951
From: David Eppstein
Date: Sat, 06 May 1989 20:20
32 lines
1652 bytes
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
Technical Details
Message-ID: <6311@columbia.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!columbia!garfield!eppstein

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!rutgers!columbia!garfield!eppstein
From: eppstein@garfield (David Eppstein)
Newsgroups: gnu.g++.bug
Subject: stupid warning
Message-ID: <6311@columbia.edu>
Date: 6 May 89 20:20:06 GMT
Sender: news@columbia.edu
Organization: Columbia University CS Department
Lines: 32