Are X, X::X, and X::X::X (and etc.) the same thing, where X is C++ class name?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/12135498/why-are-redundant-scope-qualifications-supported-by-the-compiler-and-is-it-lega">Why are redundant scope qualifications supported by the compiler, and is it legal?</a>  </p>
</blockquote>



<p>I surprisingly found that the following code compiles with g++ 3.4/4.1/4.4, clang++ 3.1 (but not with gcc 4.6/4.7).</p>

<pre><code>class X {};

int main()
{
  X::X x;
  return 0;
}
</code></pre>

<p>Changing <code>X::X</code> to <code>X::X::X::X</code> works as well. Is this valid code? And if so, where in the standard is it defined?</p>

<p>Some background. I came up with this code because I saw something like this in clang's AST matcher framework:</p>

<pre><code>///     (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
///   class X {};  // Matches X, because X::X is a class of name X inside X.
</code></pre>

<p>What interested me was its saying "X::X is a class of name X inside X". Please advise. Thanks!</p>
