gcc produces an error for the code below: bit-field.C:6: error: attempt to take address of bit-field structure member 'S::j'
In this case field j is guaranteed to be byte-aligned. gcc shouldn't have such a rigid requirement that one can't get an address of any bit field variable but should allow getting such address when it's actually possible. For example I've set bit field attribute (:8) to limit some small enum-typed field to just 8 bits. And after this I couldn't get it's address as of uint8_t value. --- code --- struct S { int j:8; }; char& cc(S *s) { return ((char&)s->j); } -- Summary: Getting an address of a byte-aligned field declared as a bit-field should be allowed Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yuri at tsoft dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36483