g++: Exception handling in constructor

Rob Shearer Rob.Shearer@networkinference.com
Wed Dec 11 01:41:00 GMT 2002

>From the standard:
15.3.16: "The exception being handled is rethrown if control reaches the
end of ahandler of the function-try-block of a constructor or

I don't really see any other choice: the object couldn't be constructed,
so you can't just return from the constructor and silently leave the
caller with uninitialize memory.

> -----Original Message-----
> From: Frank Grimm [mailto:fgr@foobar-cpa.de] 
> Sent: 11 December 2002 06:34
> To: gcc-help@gcc.gnu.org
> Subject: Re: g++: Exception handling in constructor
> Hi,
> On Tue, Dec 10, 2002 at 04:25:27PM -0800, Gokhan Kisacikoglu wrote:
> > This is not throwing that exception
> What do you mean with "not throwing that exception"? The 
> example throws                                  
> "too much" exceptions, because the Exception from the Bad 
> constructor is                                 
> caught in the constructor of Test class _and_ is re-thrown to 
> the main                                   
> function. This does IMHO not comply to the standart -- 
> because unwanted                                  
> re-throwing does not make sense. So it is probably a bug, but 
> I did not                                  
> find anything about it in the gcc bug database...   
> -- 
> Frank Grimm // fgr@foobar-cpa.de
>             // www.foobar-cpa.de

More information about the Gcc-help mailing list