This is the mail archive of the gcc-help@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]

How to use -Wsuggest-final-types/methods?


I don't really understand this option.  I enabled it but it warns for
essentially all of my classes which have any virtual methods.  For
example if I have Foo.h:

  class Foo {
      virtual bool bar();
    ...
  };

then Foo.cpp which implements Foo.  And then in another header somewhere
else I inherit from Foo and implement bar() differently (as a virtual
function).  However when GCC compiles Foo.cpp it can't see the other
header, so I guess it assumes no one inherits from Foo and suggests it
should be marked final:

  Declaring type 'class Foo' final would enable devirtualization of N calls

I mean sure, it would, but that would defeat the entire point (as I
understand it).

I don't really understand how/where this option is meant to be used. 
Ditto for -Wsuggest-final-methods.


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