Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Correct or Not or Old-fashioned or Bug Message-ID: <19804@crdgw1.crd.ge.com> Date: 22 May 91 15:43:21 GMT References: <1991May21.150735.12200@convex.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Distribution: comp.lang.c Lines: 28 In article <1991May21.150735.12200@convex.com>, grogers@convex.com (Geoffrey Rogers) writes: |>In non-ANSI C compiler/loader environments this may or may not work. You |>could get multiple defined symbols for i, depending upon the model that the |>compiler used for external variables. |> |>The above code in not ANSI conforming, because you do have multiple |>definitions of i. I think so far I have seen about 3 or 4 wrong answers to this question, such as the above. There is nothing wrong with the referenced code as far as the Standard is concerned. There are not multiple definitions of i, because none of those *tentative* definitions has an initializer. In such a situation, all tentative definitions are treated as a single definition with initializer 0. (See A10.2 in K&R2 for an explanation) -Chris |>+------------------------------------+---------------------------------+ |>| Geoffrey C. Rogers | "Whose brain did you get?" | |>| grogers@convex.com | "Abbie Normal!" | |>| {sun,uunet,uiucdcs}!convex!grogers | | |>+------------------------------------+---------------------------------+ ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com