"using namespace std" does not issue an error or warning when the namespace std
is not declared. Using other namespaces that are not declared issue a warning.

Expects:
"using namespace std;" to issue the error 
error: ‘std’ is not a namespace-name.
when namespace std is not defined. 

System:
2.6.18-1.2200.fc5 #1 Sat Oct 14 16:59:26 EDT 2006 i686 athlon i386 GNU/Linux
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)

Test Case that passes but should fail:
using namespace std;
int main () {
  return 0;
}

Test case that passes and should pass:
#include <iostream>
using namespace std;
int main () {
  return 0;
}

This code fails to compile as expected.

using namespace __gnu_cxx;
#include <ext/numeric>
int main () {
  return 0;
}

An issues the error 
‘__gnu_cxx’ is not a namespace-name


This code compiles as expected;

#include <ext/numeric>
using namespace __gnu_cxx;
int main () {
  return 0;
}

Also seen in
- gcc32 (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-55.fc5)

Command line to compile:
[EMAIL PROTECTED] testnamespace]$ make
make  all-am
make[1]: Entering directory `/home/brandon/bugs/testnamespace'
if g++ -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -MT testnamespace.o -MD -MP -MF
".deps/testnamespace.Tpo" -c -o testnamespace.o testnamespace.cpp; \
then mv -f ".deps/testnamespace.Tpo" ".deps/testnamespace.Po"; else rm -f
".deps/testnamespace.Tpo"; exit 1; fi
g++  -g -O2   -o testnamespace  testnamespace.o
make[1]: Leaving directory `/home/brandon/bugs/testnamespace'
[EMAIL PROTECTED] testnamespace]$


-- 
           Summary: Expect error when 'using namespace std' is declared when
                    std namespace is not defined
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brandon at rioja dot us
 GCC build triplet: i686-redhat-linux-gnu
  GCC host triplet: i686-redhat-linux-gnu
GCC target triplet: i686-redhat-linux-gnu


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

Reply via email to