This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to use -Wsuggest-final-types/methods?
- From: Paul Smith <paul at mad-scientist dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 26 Oct 2016 09:17:32 -0400
- Subject: How to use -Wsuggest-final-types/methods?
- Authentication-results: sourceware.org; auth=none
- Reply-to: paul at mad-scientist dot net
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.