From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Wilson To: Ruediger Helsch 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 13:36:00 -0000 Message-id: <199608131920.MAA26625@cygnus.com> References: X-SW-Source: 1996/msg00089.html 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. A very similar case is identifier names. Consider this program: int abcdef1; int abcdef2; This is not a strictly conforming program. The standard says that only the first 6 characters are guaranteed to be significant, and it is implementation defined whether any characters after the first 6 are used. Gcc however accepts this program without complaint, and it would be very unwise to change this. In this case, we do not want to enforce the strict limits of the standard, because that is far too inconvenient for programmers. It is debatable whether multiple external definitions deserves the same treatment. It is not a bug in gcc that it accepts them though. Jim