https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107263
Bug ID: 107263 Summary: Memcpy not elided when initializing struct Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jmuizelaar at mozilla dot com Target Milestone: --- With the following code struct Foo { Foo* next; char arr[580]; }; void ctx_push(Foo* f) { Foo tmp = { f->next }; *f = tmp; } Clang is able to generate code that just memsets `arr`. GCC instead initializes the entire struct on the stack and then copies it into `f`. https://gcc.godbolt.org/z/Yzcbs4G71