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]

[Bug c++/68391] -Wsuggest-override does not work on Item 12 of Effective Modern C++


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68391

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2017-08-22
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to rhalbersma from comment #0)
> Item 12 of Effective Modern C++ contains this example:
> 
> class Base {
> public:
>     virtual void mf1() const;
>     virtual void mf2(int x);
>     virtual void mf3() &;
>     void mf4() const;
> };
> 
> class Derived: public Base {
> public:
>     virtual void mf1();
>     virtual void mf2(unsigned int x);
>     virtual void mf3() &&;
>     void mf4() const;
> };
> 
> int main(){}
> 
> gcc -Wsuggest-override does not yield a single warning (-Wall -Wextra
> -pedantic don't help either).

I get these warnings:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wsuggest-override
-Woverloaded-virtual -Weffc++ 68391.cc
68391.cc:1:7: warning: ‘class Base’ has virtual functions and accessible
non-virtual destructor [-Wnon-virtual-dtor]
 class Base {
       ^~~~
68391.cc:9:7: warning: base class ‘class Base’ has accessible non-virtual
destructor [-Wnon-virtual-dtor]
 class Derived: public Base {
       ^~~~~~~
68391.cc:9:7: warning: ‘class Derived’ has virtual functions and accessible
non-virtual destructor [-Wnon-virtual-dtor]
68391.cc:3:18: warning: ‘virtual void Base::mf1() const’ was hidden
[-Woverloaded-virtual]
     virtual void mf1() const;
                  ^~~
68391.cc:11:18: warning:   by ‘virtual void Derived::mf1()’
[-Woverloaded-virtual]
     virtual void mf1();
                  ^~~
68391.cc:4:18: warning: ‘virtual void Base::mf2(int)’ was hidden
[-Woverloaded-virtual]
     virtual void mf2(int x);
                  ^~~
68391.cc:12:18: warning:   by ‘virtual void Derived::mf2(unsigned int)’
[-Woverloaded-virtual]
     virtual void mf2(unsigned int x);
                  ^~~
68391.cc:5:18: warning: ‘virtual void Base::mf3() &’ was hidden
[-Woverloaded-virtual]
     virtual void mf3() &;
                  ^~~
68391.cc:13:18: warning:   by ‘virtual void Derived::mf3() &&’
[-Woverloaded-virtual]
     virtual void mf3() &&;
                  ^~~
$

Sure, none of them are -Wsuggest-override specifically, but could they still be
what you were looking for?

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