Not positive this is a bug, but I think so.
This code compiles and prints 0:

#include <iostream>

namespace {
  int i = 0;
}

int main(int argc, char** argv)
{
  std::cout << "i=" << ::i << std::endl;
  return 0;
}


I'd expect it to complain that i isn't in the global namespace
(since it is in the anon/default one).
Removing the :: prefix from i also works, as it should.

Apparently, the MS VC++ .NET (a later version, not sure which)
does complain (though that doesn't necessarily mean much in itself).

Thanks.

PS: This is using the Redhat built/distrubuted:
g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.fc3)
on Fedora core 3.

-- 
           Summary: :: can access default/anon namespace instead of just
                    global namespace
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: t8 at pobox dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386 GNU/Linux
GCC target triplet: i386 GNU/Linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22066

Reply via email to