https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118114

            Bug ID: 118114
           Summary: std::call_once crashes on LoongArch when program is
                    built with -fPIC -mtls-dialect=desc
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: uwu at icenowy dot me
  Target Milestone: ---

Created attachment 59911
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59911&action=edit
The source code, available as a cpp file

When building the following quite minimal program with the flags described in
the title on LoongArch, the program cannot be executed and will crash:

```
// build with `g++ -fPIC test.cpp -mtls-dialect=desc`
#include <mutex>
#include <iostream>

std::once_flag flag;

void co()
{
        std::cout << "co" << std::endl;
}

int main()
{
        std::call_once(flag, co);
        std::call_once(flag, co);
}
```

Removing either flag can make the built program runs successfully and output
`co` as expected.

Reply via email to