title: Why can't I return a reference to a packed field?
body: <p>I use g++ to compile code with packed fields. However, I receive an error when trying to return a reference to a packed field.</p>
  
  <p>Example: </p>
  
  <pre><code>struct __attribute__((packed)) Foo {
     int* ptr;
     uint16_t foo;
     int*&amp; getPtr(){
        return ptr;
     }
  };
  </code></pre>
  
  <p>yields error:</p>
  
  <pre><code>test.cpp:22:14: error: cannot bind packed field ‘((Foo*)this)-&gt;Foo::ptr’ to ‘int*&amp;’
     return ptr;
  </code></pre>
  
  <p>Why can't I return a reference to a packed field?</p>