public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109268] New: Guard variable still provided for static constinit variable
@ 2023-03-24  0:48 barry.revzin at gmail dot com
  2023-03-24  0:50 ` [Bug c++/109268] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: barry.revzin at gmail dot com @ 2023-03-24  0:48 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-16 23:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24  0:48 [Bug c++/109268] New: Guard variable still provided for static constinit variable barry.revzin at gmail dot com
2023-03-24  0:50 ` [Bug c++/109268] " pinskia at gcc dot gnu.org
2023-03-24  0:54 ` pinskia at gcc dot gnu.org
2023-03-24 11:54 ` [Bug c++/109268] Guard variable still provided for static constinit variable with an empty destructor jakub at gcc dot gnu.org
2024-03-16 22:37 ` pinskia at gcc dot gnu.org
2024-03-16 23:18 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).