title: dereferencing type-punned pointer will break strict-aliasing rules
body: <p>I have a unsigned char pointer which contains a structure.Now I want to do the following</p>
  
  <pre><code>unsigned char buffer[24];
  
  //code to fill the buffer with the relevant information.
  
  int len = ntohs((record_t*)buffer-&gt;len);
  </code></pre>
  
  <p>where record_t structure contains a field called len.I am not able to do so and am getting the error.</p>
  
  <pre><code>error: request for member ‘len’ in something not a structure or union.
  </code></pre>
  
  <p>Then I tried:</p>
  
  <pre><code>int len = ntohs(((record_t*)buffer)-&gt;len);
  </code></pre>
  
  <p>so as to get the operator precedence right. That gave me the <code>warning:
  dereferencing type-punned pointer will break strict-aliasing rules</code>.</p>
  
  <p>then I declared </p>
  
  <pre><code>record_t *rec = null;
  
  rec = (record_t*)
  </code></pre>
  
  <p>what am I doing wrong here?</p>