This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with putenv() in global constructor


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]