On Tuesday 13 of March 2012, Stephan Bergmann wrote:
On 03/13/2012 11:43 AM, Tor Lillqvist wrote:
Hmm, now that the reason for using -Wno-non-virtual-dtor has been
documented (760e0d2d7329ca6fc00a8439715bae38becb168a ), I wonder,
should we globally then also turn off the corresponding MSVC warning?
That would be kinda predictable (from a "the usual waste of time"
point of view), as I and others have committed over times dozens of
WaE fixes for this very issue... (I.e. added a virtual no-op
destructor in most cases).
Or does gcc and MSVC warn for different cases of lack of virtual
destructor? Is it certain that in all cases this warning is bogus, in
both the gcc and MSVC cases?
I think the warning is generally non-bogus. The problem is that we were
not able to change the cppumaker-generated C++ headers without breaking
backwards compatiblity[1], and GCC was somewhat over-ambitious with this
warning[2], so had to disable it -- even if we would have preferred to
keep it on.
The original message about the problem,
http://markmail.org/message/664jsoqe6n6smy3b , mentions that it is not
possible to selectively disable the warning for just the classes where we
need to keep the binary compatibility.
Assuming that my attached testcase correctly matches the problem, I do not
see a warning with either gcc-4.6.3 or clang-3.1r152540. So it looks like we
can either just enable the warning and selectively disable it, or we can have
a configure check if some older gcc version has the problem (well, given that
#pragma diagnostic is recent with gcc, it'll need an #ifdef anyway).
$ g++ -Wall dtor.cpp -Wnon-virtual-dtor -c
--
Lubos Lunak
l.lunak@suse.cz
#include "dtor.h"
class C
: public B< int >
{
public:
// virtual ~C();
};
//#define NOWARN
#ifdef NOWARN
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class A
{
public:
virtual void foo();
};
template< typename T >
class B
{
public:
virtual void foo();
};
#ifdef NOWARN
#pragma GCC diagnostic pop
#endif
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.