title: Is struct { } x; an anonymous struct?
body: <p>Clang, GCC and Visual Studio 2013 complain about this piece of code.</p>
  
  <pre><code>struct { };
  </code></pre>
  
  <p>Clang with <code>-Weverything</code>:</p>
  
  <blockquote>
    <p>warning: anonymous structs are a GNU extension
    <code>[-Wgnu-anonymous-struct]</code></p>
  </blockquote>
  
  <p>GCC with <code>-Wall -Wextra -pedantic</code>:</p>
  
  <blockquote>
    <p>warning: ISO C++ prohibits anonymous structs <code>[-Wpedantic]</code></p>
  </blockquote>
  
  <p>Visual Studio 2013 with <code>/W4</code>:</p>
  
  <blockquote>
    <p>warning <a href="http://msdn.microsoft.com/en-us/library/7y0f9tby.aspx" rel="nofollow">C4094</a>: untagged 'struct' declared no symbols</p>
  </blockquote>
  
  <p>As soon as I add a variable declaration, the warnings disappear.</p>
  
  <pre><code>struct { } x;
  </code></pre>
  
  <p>And all three complain about an unused variable.</p>
  
  <p>I assume this is still an anonymous struct and illegal C++ and that the compilers stop warning for some reason. But since the behavior persists in three separate compilers, I wanted to know if adding a variable declaration somehow changes the semantics of the program.</p>
  
  <hr />
  
  <p>If this is an illegal program, <code>-pedantic-errors</code> doesn't cause either Clang or GCC to result in a compilation error. Similarly for Visual Studio, <code>/Za</code> should force a compilation error but it doesn't.</p>