🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #2104

bug 12178901 (1.36.1) - linkage of global const objects

#2104
From: Michael Tiemann
Date: Mon, 18 Dec 1989 20:32
29 lines
1502 bytes
   Date:     Sun, 17 Dec 89 11:36:06 PST
   From: rfg@ics.uci.edu


   // bug 12178901 - linkage of global const objects

   // What is the `linkage' of const objects in C++?

   // GCC generates code for the following such that `ci' has
   // extern linkage, and such that its initial value is 99.

   // G++ 1.36.1 however optimizes this declaration into nothing.
   // Thus, if some other file contained `extern const int ci;'
   // that other file would fail to link.

   const int ci = 99;

If you want GNU C++ to export these declarations, it is sufficient
only to declare `extern const int ci;' prior to declaring its initial
value.  This gives expected behavior in expected case, namely that the
file which provides the definition of ci will also include a files
which contains its extern declaration.

Unless you have been asleep for the past year, you know that declaring
things extern in C files (rather than in .h files) is more and more
becomming a no-no.

Michael
Technical Details
Message-ID: <8912182032.AA02067@lurch.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
References: <8912171136.aa08237@ICS.UCI.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!LURCH.STANFORD.EDU!tiemann
From: tiemann@LURCH.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++.bug
Subject: bug 12178901 (1.36.1) - linkage of global const objects
Message-ID: <8912182032.AA02067@lurch.Stanford.EDU>
Date: 18 Dec 89 20:32:39 GMT
References: <8912171136.aa08237@ICS.UCI.EDU>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 29