Five conditions must be true to get that bug: 1. Method throwing exception must have an exception specifier. 2-4. Method calling the method above must be VIRTUAL, must not have an exception specifier and must be called through base class pointer or reference. 5. Compile with option -On, n > 0. ---- Lev Assinovsky Aelita Software Corporation O&S InTrust Framework Division, Team Leader ICQ# 165072909 > -----Original Message----- > From: Tony Wetmore [mailto:tony.wetmore@xxxxxxxxxxxx] > Sent: Wednesday, March 10, 2004 6:23 PM > To: 'Eljay Love-Jensen'; Assinovsky, Lev; gcc-help@xxxxxxxxxxx > Subject: RE: Great g++ bug! Local destructor isn't called! > > > Interestingly, ~Object() is also called if you ADD a "throw(int)" > specifier to the FromBase::Run() method that invokes the Raiser > constructor. Tested on Linux with GCC 3.3.1. > > --- > Tony Wetmore > Raytheon Solipsys > mailto:tony.wetmore@xxxxxxxxxxxx > http://www.solipsys.com > > > > > -----Original Message----- > From: gcc-help-owner@xxxxxxxxxxx > [mailto:gcc-help-owner@xxxxxxxxxxx] On > Behalf Of Eljay Love-Jensen > Sent: Wednesday, March 10, 2004 9:46 AM > To: Assinovsky, Lev; gcc-help@xxxxxxxxxxx > Subject: Re: Great g++ bug! Local destructor isn't called! > > > Hi Lev, > > I notice that if the throw(int) specification is taken off the Raiser > constructor, then the ~Object() is called with -O3. > > (I'm using GCC 3.3.1 on CygWin / Windows XP.) > > Very odd. Good catch. Have you filed a bug? > > BTW, in general, I've found that it's usually best NOT to put > in throw > specifications for functions / methods. Ever. (This restriction does > not > apply to putting in the "throw() -- I throw nothing, ever" > specification. But even that should be used with great caution.) > > If C++ did exception specifications like how Java does them, > then that'd > be > a different story. > > --Eljay > > >