Bug 49630 - g++ uses namespace std by default
Summary: g++ uses namespace std by default
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.1
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2001-07-21 23:22 UTC by Wagner T. Correa
Modified: 2007-04-18 16:34 UTC (History)
0 users

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

Attachments (Terms of Use)

Description Wagner T. Correa 2001-07-21 23:22:26 UTC
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 11:58:29 UTC
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 18:38:00 UTC
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.