This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20293] New: namespace name lost
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Mar 2005 22:19:36 -0000
- Subject: [Bug c++/20293] New: namespace name lost
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In:
namespace hide {
int k;
}
namespace {
int i;
namespace hide {
int j;
}
}
void F(int) {}
int main() {
F(i);
F(hide::j);
}
you get:
~/ootbc/members/src$ g++ foo.cc
foo.cc: In function `int main()':
foo.cc:16: error: `hide' has not been declared
foo.cc:16: error: `j' undeclared (first use this function)
foo.cc:16: error: (Each undeclared identifier is reported only once for each
function it appears in.)
i.e. the lookup for "hide" fails whereas a simple variable "i" is found.
My (probably erroneous) understanding is that the anonymous namespace has no
impact on name scope; exports all names declared within it to filescope; and
simply replaces the old "static" to prevent cluttering the linker namespace.
That seems to be the case with "i". However, if that rule were applied to "hide"
then the two "hide"s would be at the same level and would merge as namespaces
do, rather than the inner one being hidden as happened. This problem arose
because I was trying to declare a filescope name ("j") in a way that *neither*
cluttered the compiler's space nor the linkers.
If this is in fact an error, please change this report to a complaint about the
diagnostic.
Ivan
--
Summary: namespace name lost
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20293