* Thomas Rodgers: > + static __gthread_t > + _S_get_tid() noexcept > + { > +#ifdef __GLIBC__ > + // For the GNU C library pthread_self() is usable without linking to > + // libpthread.so but returns 0, so we cannot use it in single-threaded > + // programs, because this_thread::get_id() != thread::id{} must be true. > + // We know that pthread_t is an integral type in the GNU C library. > + if (!__gthread_active_p()) > + return 1; > +#endif > + return __gthread_self(); > + }
This comment seems outdated or incomplete. pthread_self returns a proper pointer since glibc 2.27, I believe. I'm also not sure how the difference is observable for the libstdc++ implementation. Late loading of libpthread isn't quite supported.