non-local static object initialization problems

A

Ali

My problem is quite similar to Item 10 of Effective C++ (Scott
Meyers):

http://www.awprofessional.com/content/downloads/meyerscddemo/DEMO/EC/EI10_FR.HTM

I have Airplane objects declared in a namespace myNamespace in a file
main.cpp, the memPool is initialized correctly. Everything works fine
on Win32 platform with MinGW GCC 3.4.4, Borland C++ Builder 6, Visual
Studio 2003 and Visual Studio 2005.

On Linux with GCC 3.3.5 and Intel C++ Compiler 8.1 i get segmentation
fault, i could find the reason: memPool is not yet initialized when
the constructor is called for the Airplane objects in myNamespace.

Could anyone explain why?

Many thanks in advance,

Ali
 
R

red floyd

Ali said:
My problem is quite similar to Item 10 of Effective C++ (Scott
Meyers):

http://www.awprofessional.com/content/downloads/meyerscddemo/DEMO/EC/EI10_FR.HTM

I have Airplane objects declared in a namespace myNamespace in a file
main.cpp, the memPool is initialized correctly. Everything works fine
on Win32 platform with MinGW GCC 3.4.4, Borland C++ Builder 6, Visual
Studio 2003 and Visual Studio 2005.

On Linux with GCC 3.3.5 and Intel C++ Compiler 8.1 i get segmentation
fault, i could find the reason: memPool is not yet initialized when
the constructor is called for the Airplane objects in myNamespace.

Could anyone explain why?

You didn't really post enough info to answer your question (see FAQ 5.8,
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8), but I
suspect you've run into the static initialization order fiasco. See
FAQ's 10.12 through 10.16 (http://www.parashift.com/c++-faq-lite/ctors.html)
 
R

red floyd

Ali said:
[redacted]

Oh, and please don't multi-post (that is, post the same question to
multiple newsgroups separately). This has been multi-posted to
comp.lang.c++, comp.lang.c++.moderated, and gnu.g++.help, at the very least.

If you're going to post to multiple newsgroups then cross-post (specify
multiple newsgroups when submitting), after first making sure it's
topical on all listed groups.
 
A

Ali

Hello,

Many thanks for your valuable reply. I think i can solve the problem
according to the link you have sent.

As for multi-posting, when i realized that it was a bad idea, i
deleted my post and it seemed to be disappeared. However you could
answer to my deleted post somehow.

Could you please re-send (copy-and-paste) your post to comp.lang.c+
+.moderated?

Many thanks, and sorry for the inconvenience,

Ali

P.S.: I tried to send this to your e-mail address, but it returned
"DNS Error: Domain name not found".

red floyd írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top