gcc -Woverloaded-virtual

André Wöbbeking Woebbeking at kde.org
Sat Nov 17 13:53:14 GMT 2007


On Friday 16 November 2007, Allen Winter wrote:
> Howdy,
>
> Vir and I think we should add the gcc option -Woverloaded-virtual to
> the CXXFLAGS. Can we do this?
>
> From the gcc man page:
>
>        -Woverloaded-virtual (C++ only)
>            Warn when a function declaration hides virtual functions
> from a base class. For example, in:
>
>                    struct A {
>                      virtual void f();
>                    };
>
>                    struct B: public A {
>                      void f(int);
>                    };
>
>            the "A" class version of "f" is hidden in "B", and code
> like:
>
>                    B* b;
>                    b->f();
>
>            will fail to compile.

It can be very handy but there're too many false positives, e.g. if 
virtual void A::f(int) also exists. IMO too many to make this a default 
option.


Cheers,
André




More information about the kde-core-devel mailing list