From owner-freebsd-chat Tue Dec 8 05:04:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA22844 for freebsd-chat-outgoing; Tue, 8 Dec 1998 05:04:04 -0800 (PST) (envelope-from owner-freebsd-chat@FreeBSD.ORG) Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA22835 for ; Tue, 8 Dec 1998 05:04:02 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.1a/8.9.1) with ESMTP id OAA15011; Tue, 8 Dec 1998 14:03:53 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id OAA28012; Tue, 8 Dec 1998 14:03:52 +0100 (MET) Message-ID: <19981208140351.A13839@follo.net> Date: Tue, 8 Dec 1998 14:03:51 +0100 From: Eivind Eklund To: Greg Lehey , jobaldwi@vt.edu, freebsd-chat@FreeBSD.ORG Subject: Re: gcc and dup variables... References: <19981208150459.Q12688@freebie.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2i In-Reply-To: <19981208150459.Q12688@freebie.lemis.com>; from Greg Lehey on Tue, Dec 08, 1998 at 03:04:59PM +1030 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tue, Dec 08, 1998 at 03:04:59PM +1030, Greg Lehey wrote: > > It seems that ld has merged these two references into the same > > thing, > > This is a feature, not a bug. Your feature - my bug. I consider this a very long-standing bug in Unix ld. > > with some rather interesting side effects when I tried to print the > > string out after opening the file. > > Indeed :-) > > > I would've thought that I would have gotten a linker > > error for duplicate symbols of conflicting types, but I guess that ld treats > > all pointers the same as it doesn't know types? But, I also thought that if > > two modules both had non-external vars of the same name ld should've flagged > > that instead of silently merging the two. So a) is this how ld is supposed to > > work > > Yes. No. 5 An external definition is an external declaration that is also a definition of a function or an object. If an identifier declared with external linkage is used in an expression (other than as part of the operand of a sizeof operator), somewhere in the entire program there shall be exactly one external definition for the identifier; otherwise, there shall be no more than one.117 Section 6.7.5 of the draft standard (I don't have the original handy; the text for this part is just about identical). > > and b) if so, why? > > Because nobody ever got round to defining arbitrary types for the C > linker. Beep! Operator error - please try again at another time. This has been done at various times by various parties. I believe one example of such a definition is contained in a standard for something called 'ELF'. > > I can see how if one was two lazy to declare variables extern > > everywhere but once that this would be helpful, but I'd rather ld > > give me a link error as it can lead to some interesting bugs. > > This is one of the reasons why people like Bruce snoop around and put > 'static' in front of every variable which will take it. I believe I took care all of 'em last week, except for the ones in CAM, which I just bounced to Justin. You should expect a commit Real Soon Now. Eivind. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message