title: Is the typedef-name optional in a typedef declaration?
body: <p>I was quite surprised when I saw the following code compile without errors or warnings in g++-4.2:</p>
  
  <pre><code>typedef enum test { one };
  </code></pre>
  
  <p>My assumption was that if you used the <code>typedef</code> keyword it would require an extra identifier as in:</p>
  
  <pre><code>typedef enum test { one } test;
  </code></pre>
  
  <p>As already mentioned, g++-4.2 accepts it without even a warning. Clang++ 3.0 warns "<em>warning: typedef requires a name</em>", similarly Comeau warns "<em>warning: declaration requires a typedef name</em>", and g++-4.6 informs: "<em>warning: 'typedef' was ignored in this declaration</em>".</p>
  
  <p>I have not been able to identify where in the standard this is allowed, and I find it slightly confusing that two of the compilers warn that it is <em>required</em>, shouldn't it be an error if the typedef-name is <em>required</em> but not present?</p>
  
  <p><strong>UPDATE</strong>: I have checked in C with the same compilers. Clang and comeau yield the same output, gcc gives a warning: "<em>warning: useless storage class specifier in empty declaration</em>", which seems even more confusing.</p>
  
  <p><strong>UPDATE</strong>: I have checked removing the name of the enum and the results are the same:</p>
  
  <pre><code>typedef enum { one };
  </code></pre>
  
  <p>Similarly with a named struct:</p>
  
  <pre><code>typedef struct named { int x };
  </code></pre>
  
  <p>But not with an unnamed struct, in which case the code was rejected in g++ (4.2/4.6) with "<em>error: missing type-name in typedef-declaration</em>", gcc (4.2/4.6) gave a warning: "<em>warning: unnamed struct/union that defines no instances</em>", clang++ "<em>warning: declaration does not declare anything</em>", comeau "<em>error: declaration requires a typedef name</em>"</p>