https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89458
Bug ID: 89458 Summary: adding aligned attribute to struct causes too much to be copied Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: dnikitin at 3redpartners dot com Target Milestone: --- If I add __attribute__ ((aligned (256))) to a small struct, the whole 256 bytes are copied by the default copy constructor. I don't think it's correct. This is with -O3 optimization. Attached is a piece of code to demo: struct Obj { void clone(Obj& r); void clone2(Obj& r); int a; int b; int c; int c1; int c2; int c3; long c4; long c5; long c6; }__attribute__ ((aligned (256))); void Obj::clone(Obj& r) { *this = r; } built like so: g++ -O3 -std=c++14 -march=skylake The compilation result is a giant "clone" function that copies 256 bytes of memory