Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!yale!husc6!uwvax!uwmacc!jwp From: jwp@uwmacc.UUCP (Jeffrey W Percival) Newsgroups: net.unix-wizards Subject: ULTRIX linker bug??? Message-ID: <336@uwmacc.UUCP> Date: Wed, 8-Oct-86 21:36:26 EDT Article-I.D.: uwmacc.336 Posted: Wed Oct 8 21:36:26 1986 Date-Received: Thu, 9-Oct-86 03:47:24 EDT Distribution: net Organization: UWisconsin-Madison Academic Comp Center Lines: 35 I tracked down a bug in a big program I have, but was a little surprised with what I learned. My program looked like this: float x; float y; main() { ... } Now, in /usr/lib/liblocal.a, there is a subroutine whose source file looks like this: double x; double y; sub() { y = 10.0; print y x = expression; print y } I linked it with "cc main.o -llocal -o main" Much to my surprise, the value of y was changed from 10.0 to 0.0 as a result of the assignment to x. I thought (perhaps mistakenly) that the scope of a variable declared at the beginning of a file extended only throughout that file. Even if that is not true, shouldn't I have gotten a "multiply declared" message? I tried bringing sub.o into my directory and typing "cc main.o sub.o" and got the expected "multiply declared" complaint. -- Jeff Percival ...!uwvax!uwmacc!sal70!jwp or ...!uwmacc!jwp