Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!ladcgw.ladc.bull.com!pluto.hemel.bull.co.uk!pmoore From: pmoore@hemel.bull.co.uk (Paul Moore) Newsgroups: comp.lang.c++ Subject: conditional scope and destructors results Message-ID: <1990Nov13.114958.20853@hemel.bull.co.uk> Date: 13 Nov 90 11:49:58 GMT Organization: Bull HN UK Lines: 42 Well a lot of conflicting opinions expressed - thanks. They range from "desctructor calling specs are deliberately vague" to "it must be a bug" via "you shouldnt do that anyway". Tnaks to Reid Ellis for the test prog that showed that it is probably a bug in the zortech compiler. His test prog was (paraphrased) func() { cin >> i; if (i==0) return 0; foo bar; return 0; } with foo class foo{ public: ~foo{cout << "foo destruct"}; }; This works fine - i tryed on my compiler. So I went back to my code and found that I had oversimplified to example - changing the above to 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.