public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20293] New: namespace name lost
@ 2005-03-02 22:19 igodard at pacbell dot net
  2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: igodard at pacbell dot net @ 2005-03-02 22:19 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <bug-20293-6594@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2005-11-14  1:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-02 22:19 [Bug c++/20293] New: namespace name lost igodard at pacbell dot net
2005-03-02 23:01 ` [Bug c++/20293] ambiguous namespace and diagnostic, unamed namespace pinskia at gcc dot gnu dot org
2005-03-02 23:03 ` [Bug c++/20293] [3.4/4.0/4.1 regression] Wrong diagnostic for ambiguous access bangerth at dealii dot org
2005-03-02 23:24 ` giovannibajo at libero dot it
2005-03-08  2:31 ` pinskia at gcc dot gnu dot org
2005-03-11 16:27 ` lerdsuwa at gcc dot gnu dot org
2005-05-19 17:35 ` mmitchel at gcc dot gnu dot org
2005-07-22 21:17 ` pinskia at gcc dot gnu dot org
2005-09-11  1:51 ` bangerth at dealii dot org
2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
     [not found] <bug-20293-6594@http.gcc.gnu.org/bugzilla/>
2005-10-31  2:49 ` mmitchel at gcc dot gnu dot org
2005-11-14  1:32 ` mmitchel at gcc dot gnu dot org
2005-11-14  1:45 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).