From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Artem Khodush" To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: c++/3084: anonymous namespace linking Date: Fri, 08 Jun 2001 06:26:00 -0000 Message-id: <20010608132600.27348.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00292.html List-Id: The following reply was made to PR c++/3084; it has been noted by GNATS. From: "Artem Khodush" To: Cc: , Subject: Re: c++/3084: anonymous namespace linking Date: Fri, 8 Jun 2001 16:48:55 +0400 > anonymous namespace functions cannot be linked > to global call to these functions. > > There is an error when linking an object file with > the code of a function declared inside a unnamed > "namespace {}". > > In the .o that includes the function code, the name > is the form *__GLOBAL__* where in the .o that refers > to the function code, the name is different. > This is not a bug, this behavior is requred by the c++ standard, and is the very reason of existence of unnamed namespaces. 7.3.1.1 - Unnamed namespaces [namespace.unnamed] -1- An unnamed-namespace-definition behaves as if it were replaced by namespace 'unique' { /* empty body */ } using namespace 'unique'; namespace 'unique' { namespace-body } where all occurrences of 'unique' in a translation unit are replaced by the same identifier and this identifier differs from all other identifiers in the entire program.* [Footnote: Although entities in an unnamed namespace might have external linkage, they are effectively qualified by a name unique to their translation unit and therefore can never be seen from any other translation unit. --- end footnote]