Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!usc!jarthur!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: conditional scope and destructors results Message-ID: <13@microsoft.UUCP> Date: 27 Nov 90 18:18:37 GMT References: <1990Nov13.114958.20853@hemel.bull.co.uk> <329@tin.crc.ac.uk> <366@tin.crc.ac.uk> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 32 In article <366@tin.crc.ac.uk> dcurtis@crc.ac.uk (Dr. David Curtis) writes: |Jamshid Afshar has pointed out that I was wrong to say that it was not the |compiler's problem if you try to skip past an initialiser with a goto. In fact |it is illegal to do this, so the compiler ought to flag it as an error |rather than just tell you not to do it in the manual. I disagree. First, Ellis & Stroustrup do not make it clear whether this restriction is intended to be imposed on the programmer alone, or whether this is something that it is mandatory for the compiler to diagnose. But, they do say it is illegal to jump forward past an initializer -- not that it is illegal to write code that might permit a jump past an initializer. It would seem that a compiler would at least require a flow analyser to determine whether a jump might occur past an initializer in simple deterministic cases. Such a level of sophistication is not typically assumed of compilers in the design of languages. However, in other than simple deterministic cases it would seem that even compilers with flow analysers would not be able to determine if the jump will actually be executed or not. I would suspect that smart compilers would cause a compiler time error if it can be assuredly determined that a constructor is being so by-passed, send a warning in situations where the constructor might be so by-passed, and neither warn nor send an error in more complicated situations. Dumb compilers might do none of the above. In any case, since this is not a deterministic problem for compilers, it seems to me the intent of the prohibition was on programmers against such writing programs, not a requirement for compilers to detect such situations. Hopefully this is another situation where the ANSI committee will clarify the rights and responsibilities of compilers verses programmers.