I read that pthread is C library and is not compatible with C++ object model, especially when talking about exception handling.
This information is inaccurate.
how gcc/clang implements std::thread
- They call a platform-specific thread creation function.
On Linux, it is pthread_create from POSIX Threads API. You can call this function directly. See man pthreads for more details.
On Windows, that's _beginthread and _beginthreadex, which you can can call directly too.
When a thread throws an exception and it is not caught std::terminate is called.
Note that your application must be compiled and linked with -pthread flag (using -lpthread is neither necessary nor sufficient in both C and C++).
Also, how is std::thread_local implemented, related with __thread?
std::thread_local is a portable C++ storage class specifier which is an alias to a platform-specific thread-local storage class specifier. Before its introduction in C++11 people used platform-specific keywords directly for thread-local storage. Portability of thread-local storage to other platforms required writing/using/maintaining macros which expanded to platform-specific keywords for thread local storage class specifier.
std::threadis implemented is not something you should care about. Just use it.