Declaring types and templates with the same name in C++
<p>This is an academic question.</p>

<p>In the report for <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38764" rel="nofollow">GCC bug 38764</a>, there are the following examples:</p>

<pre><code>template &lt; class T &gt; struct A {};
typedef A&lt; float &gt; A; // Accepted by Comeau, but not GCC
typedef ::A&lt; float &gt; A; // Accepted by GCC but not Comeau
</code></pre>

<p>I see why the code may be invalid, but I have trouble with one of the comments:</p>

<blockquote>
  <p><em>This code is invalid but the standard says for this case no diagnostic is required so both compilers are correct according to the standard.</em></p>
</blockquote>

<p>Why is the code that is "invalid" accepted by the standard as valid? What does the standard say about this case in particular (template + type with the same name) and, in general, about namespaces for various entities (types, templates, functions, variables)?</p>
