Bug 49630 - g++ uses namespace std by default
g++ uses namespace std by default
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2001-07-21 19:22 EDT by Wagner T. Correa
Modified: 2007-04-18 12:34 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-07-22 07:58:33 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Wagner T. Correa 2001-07-21 19:22:26 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.3-12 i686)

Description of problem:
If you want to use an STL class, let's say std::vector, g++ does not
require you to write std::vector, even if you don't specify 'using
namespace std'.

How reproducible:

Steps to Reproduce:
Compile the following with 'g++ -Wall -c':
#include <vector>
vector<int> v;

Actual Results:  The code compiles with no errors or warnings.

Expected Results:  g++ should have generated an error.

Additional info:
Comment 1 Michael Schwendt 2001-07-22 07:58:29 EDT
FWIW, this is not due to g++ but due to the included libstdc++ not being
entirely standards compliant. It is not libstdc++ v3 yet which will fix this
(hopefully). If you roll your own namespaces, those work.
Comment 2 Jakub Jelinek 2001-07-22 14:38:00 EDT
g++-2.96-RH, like all g++ compilers before it, default to
-fno-honor-std, ie. std namespace is treated specially.
This is because of libstdc++-v2 which is not namespace clean etc.
Grab g++3-3.0* rpms from rawhide if you're looking for a C++
compiler which will give you error for the above.

Note You need to log in before you can comment on or make changes to this bug.