c++/7780: -Woverloaded-virtual generating false-positives
Wolfgang Bangerth
bangerth@ticam.utexas.edu
Tue Nov 26 15:47:00 GMT 2002
> > 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
More information about the Gcc-bugs
mailing list