Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: conditional scope and destructors Message-ID: <512@taumet.com> Date: 10 Nov 90 16:38:51 GMT References: <1990Nov9.151803.11426@hemel.bull.co.uk> Organization: Taumetric Corporation, San Diego Lines: 25 pmoore@hemel.bull.co.uk (Paul Moore) writes: |Problem:- if an object is only created conditionally in a function should |its destructor be called at function exit? No. |func(..) |..... | if (foo==bar) | return(z); |..... | object obj1; |.... |} |If foo does equal bar then obj is not created - should its destructor be |called when the return is done? Zortech 2.1 does call it. |It seems to me this is a bug. It is a bug. A destructor must not be called for an object which has not been constructed. It is up to the compiler to call exactly the right destructors. This is well-defined in the language. -- Steve Clamage, TauMetric Corp, steve@taumet.com