Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!garfield.columbia.edu!eppstein From: eppstein@garfield.columbia.edu (David Eppstein) Newsgroups: comp.lang.c++ Subject: static local with ctor Message-ID: <4645@columbia.UUCP> Date: Mon, 1-Jun-87 00:52:48 EDT Article-I.D.: columbia.4645 Posted: Mon Jun 1 00:52:48 1987 Date-Received: Tue, 2-Jun-87 04:02:26 EDT Sender: nobody@columbia.UUCP Organization: Columbia University CS Department Lines: 30 The version of cfront here won't let me write functions which have local static variables of a class having a constructor. This seems an unreasonable restriction to me. Also it contradicts page 158 of The Book which explicitly discusses static locals with constructors (exegesis I know but I couldn't find anything in the actual Reference Manual to contradict it). If the problem is that the initialization code needs to be able to see the scope of the variable it's initializing, it should be easy enough for cfront to translate the variable to a static global with a new name which it can guarantee is not used by anyone inappropriate. If there's some harder problem I don't see, I would be happy if someone could enlighten me; but I tend to doubt it because cfront happily accepts static globals which should be except for visibility exactly the same. As a concrete example, I get the error message line 9: sorry, not implemented: local static z of class with constructor when I run C++ on the following code. ------------ class foo { int x; public: foo(int y) { x = y; } }; bar() { static foo z(0); } -- David Eppstein, eppstein@cs.columbia.edu, Columbia U. Computer Science Dept.