title: Assign bit field member to char
body: <p>I have some code here that uses bitsets to store many 1 bit values into a char.</p>
  
  <p>Basically</p>
  
  <pre><code>struct BITS_8 {
    char _1:1;
    (...)
    char _8:1;
  }
  </code></pre>
  
  <p>Now i was trying to pass one of these bits as a parameter into a function</p>
  
  <pre><code>void func(char bit){
    if(bit){
      // do something
    }else{
      // do something else
    }
  }
  
  // and the call was
  struct BITS_8 bits;
  // all bits were set to 0 before
  bits._7 = 1;
  bits._8 = 0;
  func(bits._8);
  </code></pre>
  
  <p>The solution was to single the bit out when calling the function:</p>
  
  <pre><code>func(bits._8 &amp; 0x80);
  </code></pre>
  
  <p>But i kept going into <code>//do something</code> because other bits were set. I was wondering if this is the correct behaviour or if my compiler is broken. The compiler is an embedded compiler that produces code for freescale ASICs.</p>
  
  <p>EDIT: 2 mistakes: the passing of the parameter and that bits._8 should have been 0 or else the error would make no sense.</p>
  
  <p><strong>Clarification</strong></p>
  
  <p>I am interested in what the standard has to say about the assignment</p>
  
  <pre><code>struct X{
     unsigned int k:6;
     unsigned int y:1;
     unsigned int z:1;
  }
  
  X x;
  x.k = 0;
  x.y = 1;
  x.z = 0;
  
  char t = X.y;
  </code></pre>
  
  <p>Should now <code>t</code> contain <code>1</code> or <code>b00000010</code>?</p>