vendredi 1 avril 2016

Printing std::this_thread::get_id() gives "thread::id of a non-executing thread"?

This used to work perfectly fine (and then aliens must have hacked my PC):

#include <thread>
#include <iostream>

int main()
{
    std::cout << "What the.. : " << std::this_thread::get_id() << std::endl;

    return 0;
}

and now it prints What the.. : thread::id of a non-executing thread.

ideone.com prints some ID, but it's interesting what may have caused this behavior on my platform.

$ uname -a
Linux xxx 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Any ideas?


EDIT: Well.. when I add

std::cout << "What the.. : " << pthread_self() << std::endl;

both lines print the same ID, but when I remove it, the result is still the same - "non-executing thread".

Aucun commentaire:

Enregistrer un commentaire