First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 34
Product:  
Component:  
Status: CLOSED
Resolution: FIXED
Assigned To: Nathan Sidwell <nathan@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: martin@loewis.home.cs.tu-berlin.de
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
constsym.tgz constsym.tgz application/x-gzip 2003-05-21 15:16 4.25 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 34 depends on: Show dependency tree
Show dependency graph
Bug 34 blocks:

Additional Comments:





View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2000-03-04 13:16
 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";

------- Comment #1 From Martin v. Loewis 2000-03-08 23:22 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed as a bug

------- Comment #2 From Martin v. Loewis 2000-03-09 07:22 -------
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

------- Comment #3 From Nathan Sidwell 2000-06-23 09:08 -------
State-Changed-From-To: analyzed->feedback
State-Changed-Why: Cannot reproduce

------- Comment #4 From Nathan Sidwell 2000-06-23 16:08 -------
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


------- Comment #5 From martin@loewis.home.cs.tu-berlin.de 2000-06-25 23:14 -------
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
 


------- Comment #6 From Nathan Sidwell 2000-06-26 11:52 -------
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

------- Comment #7 From Nathan Sidwell 2000-06-28 01:39 -------
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-Why: analyzed

------- Comment #8 From Nathan Sidwell 2000-06-28 01:39 -------
State-Changed-From-To: feedback->closed
State-Changed-Why: not a bug

------- Comment #9 From Nathan Sidwell 2000-06-28 08:39 -------
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

First Last Prev Next    No search results available      Search page      Enter new bug