This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
Original-Message-Id: <m117JXo-005P8BC@siphon.tcs.hut.fi> Date: Thu, 22 Jul 1999 17:09:56 +0300 (EEST) I'm using egcs-2.91.66 and GNU ld 2.9.1 on Debian GNU/Linux "potato". I noticed that defining an extern const pointer (not necessarily pointing to a const object) causes the linker to fail. Here's a simple test: ---a.C begin--- #include<cstdio> extern const char*const c; int main () { puts (c); } ---a.C end--- ---b.C begin--- const char*const c = "hello world\n"; ---b.C end--- The linker will fail with the following message: a.o: In function `main': a.o(.text+0x4): undefined reference to `c' collect2: ld returned 1 exit status I don't know whether the standard allows the definition of extern const pointers, but I think that this is a bug. Either the compiler should issue a warning, or the name mangling code needs some fixing. Also, the demangler in the linker (and in gdb) seems to demangle the word "const" in the wrong way, e.g. "const char*" becomes "char*const". Release: 2.95.2 How-To-Repeat: [nathan] I can't reproduce this bug (current CVS, pc-linux-gnu). external global scope variable names aren't mangled. Please either confirm that this is not a bug, or provide the assembler output files and exact commands used. thanks. [mvl] I've added the requested files as attachment 0. [nathan] Not a bug. 7.1.1/6 and 3.5/3 both say that constant objects at namespace scope have internal linkage unless explicitly declared extern. I.e. this is yet another exception to regularity :-( Thus in b.cc you must write extern const char *const b = "hello world";
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed as a bug
From: loewis@gcc.gnu.org To: Marko.Makela@HUT.FI, gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org Cc: Subject: Re: c++/34 Date: 9 Mar 2000 07:22:43 -0000 Old Synopsis: [bad code] Bug in g++ name mangling with const pointers? New Synopsis: Bug in g++ name mangling with const pointers? State-Changed-From-To: open->analyzed State-Changed-By: loewis State-Changed-When: Wed Mar 8 23:22:43 2000 State-Changed-Why: Confirmed as a bug http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=34&database=gcc
State-Changed-From-To: analyzed->feedback State-Changed-Why: Cannot reproduce
From: nathan@gcc.gnu.org To: Marko.Makela@HUT.FI, gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nobody@gcc.gnu.org Cc: Subject: Re: c++/34 Date: 23 Jun 2000 16:08:26 -0000 Synopsis: Bug in g++ name mangling with const pointers? State-Changed-From-To: analyzed->feedback State-Changed-By: nathan State-Changed-When: Fri Jun 23 09:08:26 2000 State-Changed-Why: Cannot reproduce http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=34&database=gcc
From: "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> To: nathan@gcc.gnu.org Cc: Marko.Makela@HUT.FI, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org Subject: Re: c++/34 Date: Sun, 25 Jun 2000 23:14:50 +0200 > Cannot reproduce I've added the requested files as attachment 0; I managed to reproduce the problem with both 2.95.2, and 20000624. Regards, Martin
From: Nathan Sidwell <nathan@codesourcery.com> To: "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de> Cc: nathan@gcc.gnu.org, Marko.Makela@HUT.FI, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org Subject: Re: c++/34 Date: Mon, 26 Jun 2000 11:52:54 +0100 "Martin v. Loewis" wrote: > > > Cannot reproduce > > I've added the requested files as attachment 0; I managed to reproduce > the problem with both 2.95.2, and 20000624. cheers, a 30 second inspection shows that it's something to do with the optimizer refusing to emit the definition of c in b.s nathan -- Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC 'But that's a lie.' - 'Yes it is. What's your point?' nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
Responsible-Changed-From-To: unassigned->nathan Responsible-Changed-Why: analyzed
State-Changed-From-To: feedback->closed State-Changed-Why: not a bug
From: nathan@gcc.gnu.org To: Marko.Makela@HUT.FI, gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de, nathan@gcc.gnu.org, nobody@gcc.gnu.org Cc: Subject: Re: c++/34 Date: 28 Jun 2000 08:39:22 -0000 Synopsis: Bug in g++ name mangling with const pointers? Responsible-Changed-From-To: unassigned->nathan Responsible-Changed-By: nathan Responsible-Changed-When: Wed Jun 28 01:39:22 2000 Responsible-Changed-Why: analyzed State-Changed-From-To: feedback->closed State-Changed-By: nathan State-Changed-When: Wed Jun 28 01:39:22 2000 State-Changed-Why: not a bug http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=34&database=gcc