From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ruediger Helsch To: Jim Wilson Cc: Ian Lance Taylor , rms@gnu.ai.mit.edu, drepper@cygnus.com, dm@sgi.com, gcc2@cygnus.com, gas2@cygnus.com Subject: Re: global vars and symbol visibility for mips32/elf Date: Tue, 13 Aug 1996 16:06:00 -0000 Message-id: References: <199608131920.MAA26625@cygnus.com> X-SW-Source: 1996/msg00092.html On Tue, 13 Aug 1996, Jim Wilson wrote: > Wrong. A standard conforming compiler will conclaim about a multiply > defined symbol. > > This is not correct. You have missed a subtle point here. > > A program that has multiple external definitions is not a strictly conforming > program. If you want your programs to be strictly conforming, then you can not > rely on common. > > A conforming compiler must accept any strictly conforming program. However, a > conforming compiler can have extensions that allow it to accept non-strictly > conforming programs providing that such extensions do not change the behaviour > of any strictly conforming program. > > The standard says that a program with multiple external definitions results > in undefined behaviour. A standard conforming compiler can do anything when > an input program triggers undefined behaviour. Normally, we give a warning > to encourage portable programming. In this particular case, gcc chooses to > have an extensions that allows such programs to work. > > This extension is even sanctioned by the standard (in a sense), as it is > documented in the section on common extensions. But the standard allows such behaviour only if no strictly standard-conforming program is broken by the extension. The following program is strictly conforming and should continue to run: #include int optind[30000], optarg[30000]; main() { int i; for (i = 0; i < 30000; i++) { optind[i] = 1; optarg[i] = 2; } for (i = 0; i < 30000; i++) { assert(optind[i] == 1); assert(optarg[i] == 2); } return 0; } Try this to see whether your compiler conforms to the C standard! Ruediger Helsch