This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++] Weffc++/Wnon-virtual-dtor confusion
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Nathan Sidwell <nathan at acm dot org>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Fri, 4 Apr 2014 18:54:30 +0200
- Subject: Re: [C++] Weffc++/Wnon-virtual-dtor confusion
- Authentication-results: sourceware.org; auth=none
- References: <533967BE dot 1020301 at acm dot org> <20140404163809 dot GA285 at x4> <533EE25D dot 9090406 at acm dot org>
On 2014.04.04 at 17:48 +0100, Nathan Sidwell wrote:
> On 04/04/14 17:38, Markus Trippelsdorf wrote:
>
> > I'm not sure that this is a good idea. This changes the existing
> > behavior of -Wnon-virtual-dtor and causes hundreds of new warnings when
> > building LLVM. Wouldn't it make more sense to move the 3rd ed Weffc++
> > behavior to the -Weffc++ flag alone?
>
> IIUC you're using -Wnon-virtual-dtor on its own, is that right? What are the
> class shapes where you're seeing this behaviour?
>
> AFAICT the -Wnon-virtual-dtor warning was an attempt to separate out that
> particular -Weffc++ warning, but it was broken.
For example:
markus@x4 tmp % cat test.ii
class Option
{
public:
virtual ~Option ();
};
template <int> class opt_storage
{
};
template <int = 0> class A : Option, opt_storage<0>
{
};
template class A<>;
markus@x4 tmp % g++ -Wnon-virtual-dtor -std=c++11 -c test.ii
test.ii: In instantiation of âclass A<>â:
test.ii:12:16: required from here
test.ii:9:26: warning: base class âclass opt_storage<0>â has accessible non-virtual destructor [-Wnon-virtual-dtor]
template <int = 0> class A : Option, opt_storage<0>
^
markus@x4 tmp % clang++ -Wnon-virtual-dtor -std=c++11 -c test.ii
markus@x4 tmp %
(Before your commit)
markus@x4 tmp % g++ -Wnon-virtual-dtor -std=c++11 -c test.ii
markus@x4 tmp %
--
Markus