Subject: Re: B19: G++ Bug
From: [email-masked] (Volker H. Simonis)

1 Sep 1998 08:38:13 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

it's 10 days ago that i submitted nearly the same bug report 
to the mailing list, unfortunately nobody answerd. the subject
of the mail was : "B19: problem initialising global objects".
it seems to me that this is not only a problem of correctly
initialising stdio but a general problem of initialising global
objects, since it can happen in other objects like for example 
maps too.

following the text of my initial bug report :

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

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
"[email-masked]" with one line of text: "help".