Problem with putenv() in global constructor

Loren James Rittle rittle@latour.rsch.comm.mot.com
Mon Jan 13 05:17:00 GMT 2003


> I found some strange putenv() function behavior when it's used in a
> global object (C++ code) constructor.  I work on SPARC/Solaris 8
> with g++/gcc version 2.95.3 20010315 (release).  [...]

Hi,

This behavior is outside the scope of anything we can "fix" (unless we
break other global constuctor-related issues).  Your report does not
suprise me.  To be most portable, C++ programs should avoid global
constructors that will invoke library functions traditionally callable
only after main() has been invoked.  The other known trouble spots: You
will find that some systems can't properly allocate any memory before
main() is invoked.  Never attempt to start a POSIX thread before main().

Regards,
Loren



More information about the Gcc-bugs mailing list