https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109268
Bug ID: 109268 Summary: Guard variable still provided for static constinit variable Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- This program: struct X { constexpr X() { } constexpr ~X() { } }; int main() { static constinit X data; } compiled on gcc trunk with -std=c++2b -O3 emits: X::~X() [base object destructor]: ret main: movzx eax, BYTE PTR guard variable for main::data[rip] test al, al je .L14 xor eax, eax ret .L14: push rcx mov edi, OFFSET FLAT:guard variable for main::data call __cxa_guard_acquire test eax, eax jne .L15 .L5: xor eax, eax pop rdx ret .L15: mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:_ZZ4mainE4data mov edi, OFFSET FLAT:_ZN1XD1Ev call __cxa_atexit mov edi, OFFSET FLAT:guard variable for main::data call __cxa_guard_release jmp .L5 But data is constant-initialized (enforced by constinit), so there shouldn't be a need for a guard variable in this context? clang does not generate one in this case.