title: A bit field of enumeration type and a value stored to it
body: <p>I wrote the following and I expected that <code>16</code> would be printed.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  enum E : long { e = 16 };
  
  struct X 
  {
      E e : 5;
  };
  
  X x;
  
  
  int main(){ x.e = E::e; std::cout &lt;&lt; static_cast&lt;int&gt;(x.e) &lt;&lt; std::endl; }
  </code></pre>
  
  <p><strong><a href="http://coliru.stacked-crooked.com/a/7add5b99afbf91d3" rel="nofollow">DEMO</a></strong></p>
  
  <p>But it wasn't. I got a compiler warning and <code>-16</code> was printed instead. The warning was:</p>
  
  <pre><code>warning: implicit truncation from 'E' to bitfield changes value from 16 to -16 
  </code></pre>
  
  <p>It's unclear to me. Why was the warning display and why was <code>-16</code> printed? I declared the bit-field of size of <code>5</code> that's enough to store <code>16</code> in there. </p>