Consider the following code (http://coliru.stacked-crooked.com/a/b134364f7e775f87): #pragma pack(push, 1) struct foo1 { char a; int b; }; #pragma pack(pop) struct foo2 { char a; int b; } __attribute__((__packed__, aligned(1) )); int main() { foo1 f1; foo2 f2; int& i1 = f1.b; // (1) ok int& i2 = f2.b; // (2) cannot bind packed field 'f2.foo2::b' to 'int&' return 0; } (1) is valid, yet (2) produces the error. Shouldn't these behave exactly the same way, namely, (1) should also produce an error?
Confirmed. I think this is related to bug 60972.
cc-ing C++ FE maintainers
(In reply to Eric Gallager from comment #1) > Confirmed. I think this is related to bug 60972. ...and bug 92900 as well.
Reconfirmed with GCC 11.