struct A { struct { int B : 1; } } int A::*addr_anon_bitfield() { return &A::B; }
This code does not error, but instead returns a member pointer to a full int that starts at the beginning of the byte the bitfield starts on.
Paths
| Differential D27263
Address of bitfield in anonymous struct doesn't error. ClosedPublic Authored by jacobly on Nov 30 2016, 9:25 AM.
Details Summary struct A { struct { int B : 1; } } int A::*addr_anon_bitfield() { return &A::B; } This code does not error, but instead returns a member pointer to a full int that starts at the beginning of the byte the bitfield starts on.
Diff Detail
Event Timelinejacobly updated this object. This revision is now accepted and ready to land.Nov 30 2016, 9:49 AM Closed by commit rL300264: Diagnose attempt to take address of bitfield members in anonymous structs. (authored by rsmith). · Explain WhyApr 13 2017, 3:02 PM This revision was automatically updated to reflect the committed changes. Comment Actions The change to test/SemaCXX/anonymous-struct.cpp appeared to be unrelated to the rest of the patch, so I committed it separately as r300266. Thank you!
Revision Contents
Diff 95222 cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/expr-address-of.c
cfe/trunk/test/SemaCXX/ptrtomember.cpp
|