https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68051
Bug ID: 68051 Summary: copy constructor does not copy default initialized union member Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akju at mailinator dot com Target Milestone: --- The assertion at the end of the following code fails erroneously: #include <string> #include <cassert> struct test { union {int v = 0;}; std::string dummy; }; int main () { test x; x.v = 1; test y = x; assert (y.v == 1); } According to the assembly listing, it seems that the copy construction of y uses the default member initializer of v instead of x.v. This behaviour does not occur if the dummy member is removed causing the struct to be trivially copyable.