From: simonis AT debis DOT spb DOT ru (Volker Simonis) Subject: B19: problem initialising global objects 20 Aug 1998 17:40:00 -0700 Message-ID: <35DB084E.3D877FAD.cygnus.gnu-win32@debis.spb.ru> Reply-To: simonis AT debis DOT spb DOT ru Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit To: gnu-win32 AT cygnus DOT com hello, i'm using b19 with egcs1.0.2 on NT4.0. while porting a program which works fine with egcs1.02 under linux, i encountered big problems under cygwin32. it seems to me that global objects (such as for example static class members) don't get initialised properly before program start. take for example the following short program : /////////////////////////////////////////////////////////////////////////////// #include class Bug { public: Bug() { cout << "Bug() constructed" << endl; } }; int main() { Bug BUG; } //////////////////////////////////////////////////////////////////////////////// it works perfectly fine and prints out : > Bug() constructed But if we make BUG a globale variable by moving it outside of main, like in the following example : ///////////////////////////////////////////////////////////////////////////////////// #include class Bug { public: Bug() { cout << "Bug() constructed" << endl; } }; Bug BUG; int main() { } ///////////////////////////////////////////////////////////////////////////////////// we get a perfect segmentation fault, saying : > Exception: STATUS_ACCES_VIOLATION with gdb we can localize the error to happen in : --------------------------------------------------------------------------- ostream::operator<< (this=0x41100c, s=0x401040 "Bug() constructed") at libio/iostream.cc:784 ---------------------------------------------------------------------------- it seems to me that cout has not been initialized properly before the initialisation of BUG where it is used. Is this true ? as i have a lot of static and global objects with complex constructors, this is a big problem for me. does anybody know the exact reason of this error an possible workarounds ? any information appreciated. volker - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".