Is a C++11 mutex compatible with threads NOT created with C++11?

65 views
Skip to first unread message

Brian Bi

unread,
May 2, 2015, 2:09:10 AM5/2/15
to std-dis...@isocpp.org
Can we have a definitive answer to this question? It seems like people have strong opinions, but nobody seems to know for sure.

http://stackoverflow.com/questions/20445051/is-a-c11-mutex-compatible-with-threads-not-created-with-c11

I'm writing a program in which I need to be able to send signals to threads, so I have to use pthreads (there's no guarantee that a C++11 thread's native_handle is a pthread ID). C++11 mutexes and atomics are great, but I have no idea whether the standard guarantees that I can use them together with pthreads (as opposed to C++11 threads).

--
Brian Bi

Jens Maurer

unread,
May 2, 2015, 3:08:44 AM5/2/15
to std-dis...@isocpp.org
Obviously, a thread not created with C++11 is out-of-scope for the
C++ standard, so the standard can't say anything about it.

So, it's literally undefined behavior.

(It might work in a lot of today's implementations, though.)

Jens
Reply all
Reply to author
Forward
0 new messages