Unclear specification of class scope
6.3.7 [basic.scope.class]
Richard Smith

Created on 2014-09-23.00:00:00, last changed 2014-09-23.00:00:00.


Date: 2014-09-23.00:00:00

Point 2 of the rules of class scope in 6.3.7 [basic.scope.class] paragraph 1 says,

A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule.

It is not clear that this provision does not apply to names appearing in function bodies, default arguments, exception-specifications, and brace-or-equal-initializers. It is also not clear what it means to “re-evaluate” a name.

One possible approach to this problem would be to say that all names declared in a class are visible throughout the class and simply make it ill-formed to refer to a name that has not been declared yet in the contexts in which that is problematic, such as types and template arguments.

In addition, the fourth point says,

A name declared within a member function hides a declaration of the same name whose scope extends to or past the end of the member function's class.

This rule is unneeded, as it simply restates the normal hiding rule in 6.3.1 [basic.scope.declarative] paragraph 1:

The scope of a declaration is the same as its potential scope unless the potential scope contains another declaration of the same name. In that case, the potential scope of the declaration in the inner (contained) declarative region is excluded from the scope of the declaration
Date User Action Args
2014-09-23 00:00:00admincreate