[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: gcc -Woverloaded-virtual
From:       Matthias Kretz <kretz () kde ! org>
Date:       2007-11-17 14:39:02
Message-ID: 200711171539.05617.kretz () kde ! org
[Download RAW message or body]


On Saturday 17 November 2007, André Wöbbeking wrote:
> 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.

It's not really a false positive as B::f() still gets hidden, no?

I agree that you sometimes don't care, e.g. if the implementation class is 
only used casted down to the interface class. Perhaps we want to make it a 
configure switch then? Let's see how noisy it gets first I'd say...

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz@gmx.net, kretz@kde.org,
Matthias.Kretz@urz.uni-heidelberg.de

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic