jeudi 17 décembre 2020

Is there a bug in GCC 7.3.0 link thread library use -static?

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: enter image description here

Aucun commentaire:

Enregistrer un commentaire