The gcc manual does not describe the behaviour of __attribute__((packed)) attached to a class definition, e.g. class foo { unsigned char; unsigned long; } __attribute__((packed)); As far as I have observed, the behaviour is the same if foo would be declared as struct. The gcc manual describes packed only for variables, structs and enums.
Class and structs are the same by definition of the C++ standard. The only different is the default accessibility, private for class and public for struct.
Confirmed, more of the issue is really the documenation is more C based than C++ based.
Author: sandra Date: Fri Nov 16 00:50:41 2018 New Revision: 266199 URL: https://gcc.gnu.org/viewcvs?rev=266199&root=gcc&view=rev Log: 2018-11-15 Sandra Loosemore <sandra@codesourcery.com> PR c++/25759 gcc/ * doc/extend.texi (Common Type Attributes): Make it explicit that attribute "packed" can apply to C++ classes. Modified: trunk/gcc/ChangeLog trunk/gcc/doc/extend.texi
Fixed on trunk.