- Package:
- gcc
- Source:
- gcc-defaults
- Description:
- GNU C compiler
- Submitter:
- Andrew Suffield
- Date:
- 2024-04-25 17:39:19 UTC
- Severity:
- normal
- Tags:
(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).
Thank you very much for your problem report. It has the internal identification `c/7853'. The individual assigned to look at your report is: unassigned.
# submitted Debian report #159838 to gcc-gnats as PR c/7853 # http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=c/7853&database=gcc forwarded 159838 gcc-gnats@gcc.gnu.org retitle 159838 [PR c/7853] gcc reports multiple symbol definitions on the wrong line thanks
State-Changed-From-To: open->closed
State-Changed-By: ljrittle
State-Changed-When: Wed Oct 9 15:31:26 2002
State-Changed-Why:
Fixed on mainline according to Peter Schmid.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7853
State-Changed-From-To: closed->open
State-Changed-By: ljrittle
State-Changed-When: Wed Oct 9 18:25:47 2002
State-Changed-Why:
Undo, not fixed yet.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7853
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 7 02:56:17 2003
State-Changed-Why:
Confirmed still present. I think this is actually a problem
with the debug info, since one doesn't get a line number
of -g is not given.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7853
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853------- Additional Comments From pinskia@physics.uc.edu 2003-06-07 23:21 ------- The debug info contains x at line 1 so it looks like it is a ld (binutils bug) misreading the debug info: <1><78>: Abbrev Number: 3 (DW_TAG_variable) DW_AT_name : x DW_AT_decl_file : 1 DW_AT_decl_line : 1 DW_AT_type : <88> DW_AT_external : 1 DW_AT_location : 5 byte block: 3 0 0 0 0 (DW_OP_addr: 0)------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853 pinskia at physics dot uc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853 pinskia at physics dot uc dot edu changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2003-03-05 00:00:00 |2003-07-25 03:52:08 date| |------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-25 03:52 ------- I figured out what the problem is (it is not a binutils bug) but rather gcc is putting the debug information for x listed under the function foo for some reason.------- You are receiving this mail because: ------- You reported the bug, or are watching the reporter.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2003-12-26 19:51:57 |2012-01-15
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |7.5.0--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Still broken with stabs (which I think is about to removed ...): apinski@xeond:~/src/pr7853$ ~/upstream-gcc/bin/gcc -shared -g -o foo.so foo.c bar.c -gstabs /tmp/ccs5BDpP.o: In function `foo': bar.c:3: multiple definition of `x' /tmp/ccwMzLfi.o:(.bss+0x0): first defined here collect2: error: ld returned 1 exit status
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7853 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |13.2.1, 4.3.4 Status|NEW |RESOLVED Resolution|--- |FIXED--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> --- Fixed. I can't reproduce, not even with stabs (where I don't see any line info but probably due to too recent gdb). With dwarf it's also correct with GCC 4.3.