This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Problem with putenv() in global constructor
- From: Martin Sebor <sebor at roguewave dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 07 Jan 2003 12:41:11 -0700
- Subject: Re: Problem with putenv() in global constructor
- Organization: Rogue Wave Software, Inc.
- References: <200301071633.h07GX8TG001946@latour.rsch.comm.mot.com>
- Reply-to: gcc-bugs at gcc dot gnu dot org
Loren James Rittle wrote:
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.
With all respect, that seems like a pretty vague description of such
a severe restriction -- are those functions documented anywhere?
FWIW, the "problem" seems to be caused by the gcc runtime (2.95
through 3.2) and does not appear to be C++ specific (gcc exhibits
the same behavior for functions declared with the __attribute__
((constructor)) extension). On the same system, SunPro handles
fine call to putenv() in ctors of global objects.
Regards
Martin