Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.std.c Subject: Re: A question about tenative definitions Message-ID: <160@tdatirv.UUCP> Date: 5 Mar 91 20:13:13 GMT References: <4218@lupine.NCD.COM> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 37 In article <4218@lupine.NCD.COM> rfg@lupine.ncd.com (Ron Guilmette) writes: >I'm having a discussion with a C implementor I know about the meaning of >the following sentence from the ANSI C standard. > "If a translation unit contains one or more tenative definitions > for an identifier, and the translation unit contains no external > definition for that identifier, then the behavior is exactly as > if the translation unit contains a file scope declaration of that > identifier, with a composite type as of the end of the translation > unit, with an initializer equal to zero." > >What exactly does this mean? ... < Example consisting of two translation units (=files) deleted> >... if you compiled them both and then tried to link them together into >the same single program, that you should get an error at link time because >there are two conflicting external *definitions* of the variable xxyyzz. > >This implementor I know disagrees with my interpretation. > >Who is right? In essence you are right. The example you gave generates what ANSI calls 'undefined behavior'. This means that it is *not* a conforming C program. It also, generally, means that *any* behavior on the part of the system is acceptable. So, this *may* mean that the implementor's approach is a legal local *extension* to ANSI C. Of course any programs that depend on such an extension will not be portable. [It is a legal extension as long as the ANSI standard does not *require* a diagnostic for this error; I do not believe it does, so the extension is likely to be legal]. The whole matter is discussed in some detail in the rationale document. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)