I use std::call_once in my code, it compiled succeed but crashed when runing... like this demo:
#include <iostream>
#include <mutex>
using namespace std;
int main()
{
cout << "Hello world" << endl;
static once_flag of;
call_once(of,[]{});
cout << "see you again" << endl;
return 0;
}
Later I found,if i compiled with -static,it crashed,but run succeed just with -pthread or -lpthread: