This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7780: -Woverloaded-virtual generating false-positives
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: Loren Osborn <linux_dr at yahoo dot com>
- Cc: gcc-bugs at gcc dot gnu dot org, <gcc-gnats at gcc dot gnu dot org>
- Date: Tue, 26 Nov 2002 17:08:05 -0600 (CST)
- Subject: Re: c++/7780: -Woverloaded-virtual generating false-positives
> > No, this is particularly the case the warning was for. In this case you
> > are right.
> >
> > However, the fact that in _my_ example the warning is triggered is that
> > overloading the function in B also hides the other function with the
> > different numbers of parameters. You'll see this if in my example you
> > replace main with this:
> > int main()
> > {
> > B b;
> > b.ThisFunctionShouldNotCauseAHidingWarning('c');
> > }
> > One would think that this calls the single parameter function of the base
> > class, but in fact the two-parameter function in the derived class also
> > hides the single-parameter function! So, even without
> > -Woverloaded-virtual, you'll get an _error_, not a _warning_. The warning
> > is there to warn you about this fact even if you do not attempt to
> > actually call the function.
> >
> > Does this clarify the usefulness of the warning somehow?
>
> Is this how ANSI C++ says it's supposed to work? or is this a bug in
> g++???
Strange enough, but this is indeed a relic of very early C++ times that
made it into the standard.
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth