From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32357 invoked by alias); 20 May 2003 22:06:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32329 invoked by uid 71); 20 May 2003 22:06:00 -0000 Resent-Date: 20 May 2003 22:06:00 -0000 Resent-Message-ID: <20030520220600.32326.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, Sean 'Shaleh' Perry Resent-Reply-To: gcc-gnats@gcc.gnu.org, 188943@bugs.debian.org Received: (qmail 16844 invoked from network); 20 May 2003 21:59:31 -0000 Received: from unknown (HELO hirsch.in-berlin.de) (192.109.42.6) by sources.redhat.com with SMTP; 20 May 2003 21:59:31 -0000 Received: from tango.net.local (dsl-213-023-156-180.arcor-ip.net [213.23.156.180]) (authenticated bits=0) by hirsch.in-berlin.de (8.12.9/8.12.9/Debian-1) with ESMTP id h4KLxTaQ018510 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); Tue, 20 May 2003 23:59:30 +0200 Received: from doko by tango.net.local with local (Exim 4.20 #1 (Debian) [+araqnid]) id 19IF8n-0003fN-Sl; Tue, 20 May 2003 23:59:25 +0200 Message-Id: Date: Tue, 20 May 2003 22:06:00 -0000 From: Matthias Klose Reply-To: 188943@bugs.debian.org To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: Sean 'Shaleh' Perry Subject: c++/10891: code using dynamic_cast causes segfaults when -fno-rtti is used X-SW-Source: 2003-05/txt/msg02218.txt.bz2 List-Id: >Number: 10891 >Category: c++ >Synopsis: code using dynamic_cast causes segfaults when -fno-rtti is used >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue May 20 22:06:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Sean 'Shaleh' Perry >Release: 3.3 (Debian) (Debian testing/unstable) >Organization: The Debian Project >Environment: System: Debian GNU/Linux (unstable) Architecture: i686 >Description: [ Reported to the Debian BTS as report #188943. Please CC 188943@bugs.debian.org on replies. Log of report can be found at http://bugs.debian.org/188943 ] 3.2.3 / 3.3 Now obviously, dynamic_cast requires rtti so using -fno-rtti is silly. I ran into this on a C++ project where we had been using -fno-rtti because rtti was not used. A recent commit added dynamic_cast code and started segfaulting. It was believed that the dynamic_cast was at fault and this caused some finger pointing. Then the no-rtti was noticed. The compiler should give a warning (or perhaps even an error) if code requiring rtti is used while the -fno-rtti option is in effect. #include class EventHandler { public: virtual ~EventHandler(void) {} virtual void thisEvent(void) {} virtual void thatEvent(void) {} }; class MyMenu: public EventHandler { public: virtual void thisEvent(void) { std::cout << "this Menu handler\n"; } virtual void thatEvent(void) { std::cout << "that Menu handler\n"; } }; class OtherThing: public EventHandler { public: virtual void thisEvent(void) { std::cout << "this OtherThing handler\n"; } virtual void thatEvent(void) { std::cout << "that OtherThing handler\n"; } }; void do_event(EventHandler* handler) { if (dynamic_cast(handler)) { // also call thatHandler for menus handler->thatEvent(); } handler->thisEvent(); } int main(int argc, char* argv[]) { MyMenu menu; OtherThing thing; do_event(&menu); do_event(&thing); exit(0); } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: