Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!mrccrc!dcurtis From: dcurtis@crc.ac.uk (Dr. David Curtis) Newsgroups: comp.lang.c++ Subject: Re: conditional scope and destructors results Message-ID: <329@tin.crc.ac.uk> Date: 14 Nov 90 12:14:08 GMT References: <1990Nov13.114958.20853@hemel.bull.co.uk> Reply-To: dcurtis@crc.ac.uk (Dr. David Curtis) Organization: MRC Human Genome Resource Centre Lines: 42 <>func() <>{ <> ..... <> if (i==0) <> goto err_exit; <> <> foo bar; <>err_exit:; <> return 0; <>} <>now fails - ie the constructor is not called but the destructor is. I'm sure <>this proves that it is a bug in the zortech compiler since the behaviuor <>must be consistent. <> <>I'm still interested in what other compilers do as the lack of concensus <>shows that this is not clearly defined. I don't think it's fair to call this a bug. The Zortech manual has just such an example (V2.0, p.203): "Re: Using goto to skip initialisation In C this may or may not cause problems, and is certainly bad style. In C++ it can be positively disastrous since the class definition might in fact call a constructor which allocates memory, and for which a destructor will be called later." Quite so. If anything, this is a language problem, not a compiler problem. Using goto to skip initialisation? Just say no. Newsgroups: comp.lang.c++ Subject: Re: conditional scope and destructors results Summary: Expires: References: <1990Nov13.114958.20853@hemel.bull.co.uk> Sender: Reply-To: dcurtis@crc.ac.uk (Dr. David Curtis) Followup-To: Distribution: Organization: MRC Human Genome Resource Centre Keywords: