title: Strict aliasing rule uint8_t buffer to structure
body: <p>Consider I have a typedef with bit fields as below.</p>
  
  <pre><code>typedef struct VIN_oCAN01_3abd61be
  {
     uint64_t var1:24;
     uint64_t var2:4;
     uint64_t var3:4
  }__attribute__((packed))Message;
  </code></pre>
  
  <p>And I receive <code>uint8_t</code> buffer as below.</p>
  
  <pre><code>uint8_t buffer[4] = {0x1,0x2,0x3,0x14};
  </code></pre>
  
  <hr>
  
  <p>Currently in my production program my team is suggesting below approach.</p>
  
  <pre><code>Message *ptrMsg = (Message *)buffer;
  </code></pre>
  
  <p>That is, assigning <code>uint8_t</code> buffer to <code>Message</code> type pointer.
  I had suggested that proposed approach does not follow <em>strict aliasing</em> rule and instead we should do as below.</p>
  
  <pre><code>Message msg;
  memcpy(&amp;msg,buffer, sizeof(msg));
  </code></pre>
  
  <blockquote>
    <p>Note there is no option of copying the buffer to structure
    manually(member by member) as structure is very big.</p>
  </blockquote>
  
  <p>Is my understanding is correct? If so can you please provide the standard doc which I can use to prove my point.</p>