Consider the following code:
struct S {
struct type {};
type type;
};
int main() {
typename S::type t;
(void) t;
}
Apart for the fact that is far from being a good idea, I was experimenting after having read another question here on SO.
I found that the snippet above is compiled with no errors by GCC and it is rejected by clang 3.9 with the following error:
error: typename specifier refers to non-type member 'type' in 'S'
I suspect that clang is right in this case and GCC is wrong (actually, I'm opening an issue to the latter).
Is it the right conclusion or is that a valid use of typename
?
Note: I'm not asking how to solve it, I know how to do that. I'm asking only if this code is valid or not.