🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6133

Re: Exception handling

#6133
From: Alex Martelli
Date: Fri, 06 Dec 1996 00:00
33 lines
1721 bytes
wchi@students.cs.mu.oz.au (Waye-Ian CHIEW) writes:

>   class General { };
>   class Specific : public General { };

>   int main () {
>      try { 
>	 throw New Specific;
>      }

>      catch ( General* general ) { }
>   }

>  
>This falls though without catching and aborts.  Why doesn't gcc match the Specific object to General?

As a guess, I would point out the fact that the General and Specific
classes are not polymorphic; by the ANSI C++ draft standard, a compiler
only has to do runtime type identification (surely in dynamic_cast<>,
but I believe in try/throw/catch too) for objects of classes that are
polymorphic (i.e., have at least one virtual function).  This is to
avoid mandating rtti's overhead on every object.  Try adding a virtual
function in General and see if that works as you expect (I don't have
a gcc with working exception handling so I can't test that myself).


Alex
--
DISCLAIMER: these are MY personal opinions and viewpoints, NOT connected
in any way with my employer, nor any other organization or individual!
Email: martelli@cadlab.it -- Phone: +39 (51) 597 313  [Fax: 597 120]
Cad.Lab S.p.A., v. Ronzani 7/29, 40033 Casalecchio (BO), Italia
Technical Details
Message-ID: <E1zIvL.759@cadlab.it>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <199612060116.MAA09973@cat.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,b8592ac7ef932823
X-Google-Attributes: gid113d02,public
From: martelli@cadlab.it (Alex Martelli)
Subject: Re: Exception handling
Date: 1996/12/06
Message-ID: <E1zIvL.759@cadlab.it>
X-Deja-AN: 202659740
sender: news@cadlab.it
references: <199612060116.MAA09973@cat.cs.mu.OZ.AU>
organization: CAD.LAB S.p.A., Bologna, Italia
x-gateway: relay5.UU.NET from bug-gcc to gnu.gcc.bug; Fri, 6 Dec 1996 04:32:06 EST
newsgroups: gnu.gcc.bug