The lookup for T
should fail
class A
{
typedef int T;
void f(void)
{
class B {};
class C
{
class D : public B
{
void g(void)
{
T a;
}
};
};
}
};
because 3.4.1 paragraph 8 from N4567 says that
For the members of a class
X
, a name used in a member function body, in a default argument, in an exception-specification, in the brace-or-equal-initializer of a non-static data member (9.2), or in the definition of a class member outside of the definition ofX
, following the member’s declarator-id, shall be declared in one of the following ways:
- before its use in the block in which it is used or in an enclosing block (6.3), or
- shall be a member of class
X
or be a member of a base class ofX
(10.2), or- if
X
is a nested class of classY
(9.7), shall be a member ofY
, or shall be a member of a base class ofY
(this lookup applies in turn toY
’s enclosing classes, starting with the innermost enclosing class), or- if
X
is a local class (9.8) or is a nested class of a local class, before the definition of classX
in a block enclosing the definition of classX
, or- if
X
is a member of namespaceN
, or is a nested class of a class that is a member ofN
, or is a local class or a nested class within a local class of a function that is a member ofN
, before the use of the name, in namespaceN
or in one ofN
’s enclosing namespaces.
To be more specific, the lookup for T
is done as the following:
- before
T
's use ing
- shall be a member of class
D
or be a member of classB
- shall be a member of class
C
- before the definition of class
D
inf
- ???
The problem is that D
is not
- a member of a namespace,
- a nested class of a class that is a member of a namespace,
- a local class,
- a nested class within a local class of a function that is a member of a namespace,
but rather a nested class within a local class of a function that is a member of a class.