[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

gcc reports multiple symbol definitions on the wrong line



>Submitter-Id:	net
>Originator:	Andrew Suffield <aps100@doc.ic.ac.uk>
>Organization:	The Debian Project
>Confidential:	no
>Synopsis:	
>Severity:	non-critical
>Priority:	medium
>Category:	c
>Class:		sw-bug
>Release:	3.2.1 CVS (Debian) (Debian unstable)
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
	
>Description:
[ Reported to the Debian BTS as report #159838.
  Please CC 159838@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/159838 ]

Andrew Suffield writes:

(I am not sure whether this is a bug in gcc or binutils)

aps100@cyclone:~/tmp$ cat foo.c
int x = 0;

aps100@cyclone:~/tmp$ cat bar.c
int x = 0;

void foo(void) {}

aps100@cyclone:~/tmp$ gcc -shared -g -o foo.so foo.c bar.c
/tmp/cc0wTF8S.o: In function `foo':
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/aps100/tmp/bar.c:3: multiple definition of `x'
                       ^
/tmp/ccpK9pwb.o(.data+0x0):/home/aps100/tmp/foo.c: first defined here
collect2: ld returned 1 exit status
aps100@cyclone:~/tmp$ gcc-3.2 -shared -g -o foo.so foo.c bar.c
/tmp/ccBwlA8f.o: In function `foo':
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/aps100/tmp/bar.c:3: multiple definition of `x'
                       ^
/tmp/cckwx9Kb.o(.data+0x0): first defined here
collect2: ld returned 1 exit status

Note the indicated parts. Function 'foo' has got nothing to do with
the problem, and that's the wrong place to be highlighting the error.

More generally, it appears that symbol conflicts in the global scope
will always be reported as being in the first function in the
compilation unit (not thoroughly tested, but that's what I
noticed). This means the error message might not even be pointing at
the correct file, let alone the right line.

(Needless to say, this is quite irritating).



	
>How-To-Repeat:
	
>Fix:
	



Reply to: