I accidentally discovered that g ++ (5.2.0) compiles the following
template<typename T>
struct A {
int x;
struct B {
void foo() {
x = 1;
}
};
};
even istantition Aand A::Bif the item is B::foonot used. You reasonably get instead a compilation error for x, which is a non-static member A, even just by compiling the no-op operator &A<int>::B::foo;.
clang (3.6.2), however, discards the template, even if Ait is not created at all, because it says that the name of the non-static member xcannot be used internally Bby simply reading the template definition.
Is this a bug in g ++ or clang too strict for template members that are not created?