[PATCH] D19344: [libc++] fix constexpr error when build with MUSL and macro redef warning when no exception

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 17:54:10 PDT 2016


EricWF requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: include/__mutex_base:43
@@ -42,3 +42,3 @@
     _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
      constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
----------------
This is not OK. It's critical that mutex have a constexpr constructor that it runs during the "Constant initialization" phase of static initialization.
Heres an example of the difference this makes: https://godbolt.org/g/3cvlMJ

Also the constructor is specified as being constexpr in C++11. We can't turn that off. 

If one particular pthread implementation is broken then we need a fix targeted to only that implementation.  However this seems like a pthread bug and not a libc++ bug.

================
Comment at: include/__mutex_base:282
@@ -281,3 +281,3 @@
     _LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
     constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
----------------
Same as above.


http://reviews.llvm.org/D19344





More information about the cfe-commits mailing list