Re: C++ Warning for Base Class Overrides?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9 August 2011 14:10, Jeffrey Walton wrote:
>>>> If you mean
>>>> overloads, -Woverloaded-virtual will warn about virtual functions
>>>> which are hidden by functions with the same name in a derived class.
>>>> There's no warning for non-virtual functions which are hidden.
>>> That's too bad. Itel's ICC caught the typos.
>>> http://software.intel.com/en-us/articles/cdiag1125/.
>>
>> G++ gives the same warning for the example on that page.
> Intersting. I did not get one from Ubuntu 10's version of g++ (4.4.3).
> I cleaned and then compiled twice to make sure.

$ cat > in.cc
class Base{
public :
    virtual void foo (float f){ }
};

class Derived : public Base {
public :
    void foo (char c) { }
};

$ g++ -Woverloaded-virtual in.cc -c
in.cc:3: warning: 'virtual void Base::foo(float)' was hidden
in.cc:8: warning:   by 'void Derived::foo(char)'
$
$ g++ -dumpversion
4.4.3


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux