https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109833
Bug ID: 109833
Summary: The value of constexpr anonymous union can be changed
in runtime
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The code as follows is accepted by GCC
constexpr static union {
int k = 1;
};
int main() {
k = 10;
}
static_assert(k == 1);
yet crashes in runtime, online demo: https://gcc.godbolt.org/z/r5h7eEjde