From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24200 invoked by alias); 24 Jan 2008 18:17:38 -0000 Received: (qmail 23520 invoked by uid 48); 24 Jan 2008 18:16:53 -0000 Date: Thu, 24 Jan 2008 18:57:00 -0000 Message-ID: <20080124181653.23519.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/34949] Dead code in empty destructors. In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "spark at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg02925.txt.bz2 ------- Comment #4 from spark at gcc dot gnu dot org 2008-01-24 18:16 ------- I don't think this can be implemented in the FE, at least to be really effective. The more common cases are not really "empty" destructor. E.g. there's inlining involved: class Foo { public: virtual ~Foo(); }; Foo::~Foo() { } class Bar : public Foo { public: virtual ~Bar(); }; Bar::~Bar() { } where Foo::~Foo() has to be inlined before we can determine ~Bar() is really empty. But "emptiness" isn't really how we want to decide eliminating those but rather the dependence on the vtable itself. e.g.: extern "C" int printf(const char* s); class Foo { public: virtual ~Foo(); }; Foo::~Foo() { printf("good bye foo\n"); } class Bar : public Foo { public: virtual ~Bar(); }; Bar::~Bar() { printf("good bye bar\n"); } In this case, there's no need for vtable update inside the destructor (which is more common). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34949