X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Date: Wed, 11 Aug 2004 21:01:23 +0300 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp-workers AT delorie DOT com Message-Id: <1438-Wed11Aug2004210123+0300-eliz@gnu.org> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: <411A0EEF.F3DA04B4@yahoo.com> (message from CBFalconer on Wed, 11 Aug 2004 08:19:59 -0400) Subject: Re: Fix for environ pollution References: <10408102240 DOT AA89930 AT clio DOT rice DOT edu> <2719-Wed11Aug2004065357+0300-eliz AT gnu DOT org> <411A0EEF DOT F3DA04B4 AT yahoo DOT com> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > Date: Wed, 11 Aug 2004 08:19:59 -0400 > From: CBFalconer > > Just thinking out loud. That means that, within main only, and in > the DJGPP stack environment, the system has to translate the word > 'environ' to access the space for a third parameter to main. No, I don't think so. The startup code calls `main' with 3 argument, the 3rd being the addres of environ[0]. So a program that declares `main' with 3 args will get the environment, and if it doesn't, it won't. No magic translation is required. > This is in the compiler proper. That access has to be removed if > the -ansi directive is in force. ??? AFAIK, ANSI C does support the 3rd argument to `main'. So we cannot remove it under -ansi. > Thus the library proper is not affected, and can supply any names > desired in either user or system space, provided they are in > separate modules and not loaded unless specified. The whole thing > is therefore a GCC bug, not a library bug. No, the problem _is_ in the library (or, rather, in the startup code, but that also belongs to the library). `environ' is defined in the startup code (because it calls `main' with its pointer), and since the startup code is _always_ linked into the program, the symbol is always there, and it has an external linkage.