title: Is it valid to use bit fields with union?
body: <p>I have used bit field with a structure like this,</p>
  
  <pre><code>struct
  {
         unsigned int is_static: 1;
         unsigned int is_extern: 1;
         unsigned int is_auto: 1;
  } flags;
  </code></pre>
  
  <p>Now i wondered to see if this can be done with a union so i modified the code like,</p>
  
  <pre><code>union
  {
         unsigned int is_static: 1;
         unsigned int is_extern: 1;
         unsigned int is_auto: 1;
  } flags;
  </code></pre>
  
  <p>I found the bit field with union works but all those fields in the union are given to a single bit as I understood from output. Now I am seeing it is not erroneous to use bit fields with union, but it seems to me that using it like this is not operationally correct. So what is the answer - is it valid to use bit field with union?</p>