Great g++ bug! Local destructor isn't called!
Wed Mar 10 15:57:00 GMT 2004
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.
From: firstname.lastname@example.org [mailto:email@example.com] On
Behalf Of Eljay Love-Jensen
Sent: Wednesday, March 10, 2004 9:46 AM
To: Assinovsky, Lev; firstname.lastname@example.org
Subject: Re: Great g++ bug! Local destructor isn't called!
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
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
a different story.
More information about the Gcc-help