Created on 2002-08-15.00:00:00 last changed 130 months ago
[Voted into WP at August, 2010 meeting.]
Proposed Resolution (November, 2006):
Change 6.5.7 [basic.lookup.udir] paragraph 1 as follows:
When looking up a namespace-name in a using-directive or namespace-alias-definition,In a using-directive or namespace-alias-definition, during the lookup for a namespace-name or for a name in a nested-name-specifier, only namespace names are considered.
Is this case valid? G++ compiles it.
namespace X { namespace Y { struct X { void f() { using namespace X::Y; namespace Z = X::Y; } }; } }
The relevant citation from the standard is 6.5.7 [basic.lookup.udir]: "When looking up a namespace-name in a using-directive or namespace-alias-definition, only namespace names are considered." This statement could reasonably be interpreted to apply only to the last element of a qualified name, and that's the way EDG and Microsoft seem to interpret it.
However, since a class can't contain a namespace, it seems to me that this interpretation is, shall we say, sub optimal. If the X qualifiers in the above example are interpreted as referring to the struct X, an error of some sort is inevitable, since there can be no namespace for the qualified name to refer to. G++ apparently interprets 6.5.7 [basic.lookup.udir] as applying to nested-name-specifiers in those contexts as well, which makes a valid interpretation of the test possible.
I'm thinking it might be worth tweaking the words in 6.5.7 [basic.lookup.udir] to basically mandate the more useful interpretation. Of course a person could argue that the difference would matter only to a perverse program. On the other hand, namespaces were invented specifically to enable the building of programs that would otherwise be considered perverse. Where name clashes are concerned, one man's perverse is another man's real world.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | status: wp -> fdis |
2010-11-29 00:00:00 | admin | set | status: dr -> wp |
2010-08-23 00:00:00 | admin | set | messages: + msg2906 |
2010-08-23 00:00:00 | admin | set | status: review -> dr |
2008-02-03 00:00:00 | admin | set | messages: + msg1573 |
2008-02-03 00:00:00 | admin | set | status: open -> review |
2002-08-15 00:00:00 | admin | create |