Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!bloom-beacon!deccrl!news.crl.dec.com!shlump.nac.dec.com!pa.dec.com!decwrl!lattanzi From: lattanzi@decwrl.dec.com (Len Lattanzi) Newsgroups: comp.lang.c++ Subject: iostream_withassign and state variables Message-ID: <1991Jan16.005139.29552@pa.dec.com> Date: 16 Jan 91 00:51:39 GMT Sender: news@pa.dec.com (News) Organization: DEC Palo Alto Lines: 41 // Given the following 2.0 C++ #include static class MyIostream_init { static int count; static Iostream_init *io; public: MyIostream_init(); ~MyIostream_init(); }; static MyIostream_init init; static int idx; MyIostream_init::MyIostream_init() { if (count++ > 0) return; io = new Iostream_init; idx = ios::xalloc(); } MyIostream_init::~MyIostream_init() { if (--count > 0) return; delete io; } main() { cerr.iword(idx) = 1; clog.iword(idx) = 0; clog = cerr; cout << clog.iword(idx) << endl; // I expected '1' to be printed out. Glockenspiel 2.0 gave me '0', the // work-around is tedious and without an 'official' iostream // specification I'm not sure if this is a bug or feature. // Submitted for your input. } \ Len Lattanzi (Migration Software Systems Ltd 408 452 0527)