ULTRIX linker bug???

Jeffrey W Percival jwp at uwmacc.UUCP
Thu Oct 9 11:36:26 AEST 1986


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



More information about the Comp.unix.wizards mailing list