Some pthread implementations use volatile types in their structs.
C++11 does not allow initializing volatile types in constexpr constructors.
This fixes building libcxx on musl-libc and NetBSD.
Differential D21637
[libcxx] Don't use pthread initializers in constexpr constructors elram on Jun 23 2016, 1:00 AM. Authored by
Details
Some pthread implementations use volatile types in their structs. This fixes building libcxx on musl-libc and NetBSD.
Diff Detail Event TimelineComment Actions @joerg. I think this has been fixed in newer versions of NetBSD. Sure would be nice if someone could fix this on the MUSL side of things. See https://bugs.musicpd.org/view.php?id=4110 for fun conversations about mutex, PTHREAD_MUTEX_INIT and constexpr. Also, the first revision of this review: Comment Actions C++03 does not support default member initializers but libc++ provides both of these classes an extensions in C++03. I think the current patch looks good for C++11, but a fallback implementation is needed for C++03. Comment Actions Small side question: so how are __m_ and __cv_ initialized in this setup? is it that pthread_mutex_lock() and the like would be able to handle an un-initialized blob of memory (in a thread-safe way)? Because I don't see a call to pthread_mutex_init() anywhere in the code-path. Comment Actions __m_ and __cv_ are initialized during non-static data member initialization. They didn't previously call pthread_mutex_lock(), instead they directly initialized 'm_' and 'cv_' in the constructors initializer list. And according to the current spec we are allowed to use PTHREAD_MUTEX_INITIALIZER to initialize non-static mutexes.
Comment Actions Ah! I've misread the patch - missed the assignment in the constructor (for the _LIBCPP_HAS_NO_CONSTEXPR case). Sorted now. Thanks. / Asiri |