This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77945] New: GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.
- From: "eric at efcs dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Oct 2016 06:02:34 +0000
- Subject: [Bug c++/77945] New: GCC generates invalid constexpr copy/move assignment operators for types with trailing padding.
- Auto-submitted: auto-generated
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), "");