Bug 29556 - Expect error when 'using namespace std' is declared when std namespace is not defined
Expect error when 'using namespace std' is declared when std namespace is not...
Status: NEW
Product: gcc
Classification: Unclassified
Component: c++
4.1.1
: P3 minor
: ---
Assigned To: Not yet assigned to anyone
: accepts-invalid
Depends on:
Blocks: 24604
  Show dependency treegraph
 
Reported: 2006-10-23 00:31 UTC by Brandon Rioja
Modified: 2006-10-23 09:47 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 2.95 3.2.3 3.4.0 4.0.0 4.2.0 4.0.4 4.1.2 3.0.4 4.3.0
Last reconfirmed: 2006-10-23 00:48:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brandon Rioja 2006-10-23 00:31:55 UTC
"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:
[brandon@c-71-60-104-243 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'
[brandon@c-71-60-104-243 testnamespace]$
Comment 1 Andrew Pinski 2006-10-23 00:48:57 UTC
Confirmed. Related to:
http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00945.html