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]

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



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