https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77945
Bug ID: 77945 Summary: GCC generates invalid constexpr copy/move assignment operators for types with trailing padding. Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eric at efcs dot ca Target Milestone: --- The copy/move assignment operators generated by GCC result in compile time error when used in a constant expression if the type contains trailing padding bytes (but one bytes between members). Reproducer: // g++ -std=c++1z test.cpp struct OK { char no_padding = 0; constexpr OK() {} }; static_assert((OK{} = OK{}, true), ""); struct T { alignas(2) char with_padding = 0; constexpr T() {} }; // emits-error {{non-constant condition in static assert}} // emits-error {{error accessing value of '<anonymous>' through a 'char [1]' glvalue in a constant expression}} static_assert((T{} = T{}, true), "");