Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!ucbcad!moore From: moore@ucbcad.berkeley.edu (Peter X Moore) Newsgroups: comp.lang.c++ Subject: Re: Is this a bug? Message-ID: <1669@ucbcad.berkeley.edu> Date: Thu, 11-Jun-87 15:11:44 EDT Article-I.D.: ucbcad.1669 Posted: Thu Jun 11 15:11:44 1987 Date-Received: Sat, 20-Jun-87 11:42:50 EDT References: <731@boulder.Colorado.EDU> Reply-To: moore@cad.Berkeley.EDU.UUCP (Peter X Moore) Organization: UC Berkeley, CAD group Lines: 15 Keywords: streams, bug, global constructors This is not so much a bug, as an unavoidable feature of the way global constructors are implemented. Both your object and cerr have global constructors. All global constructors are grouped together and called IN ESSENTIALLY A RANDOM ORDER before main. You are having the good fortune of having your object's constructor called before cerr's constructor is called, and so the code for << is core dumping as it tries to use an unintialized data structure. The immediate patch is to either use a local stream variable instead of cerr or fall back to fprintf. To fix the general problem seems VERY tough, since it seemingly requires global interdependacy analysis between all constructors. Other languages must face this problem, does anyone know what they do (or don't do)? Peter Moore moore@Berkeley.edu ...!ucbvax!moore