https://github.com/llvm-mirror/libcxx/blob/master/include/__mutex_base#L290
class _LIBCPP_TYPE_VIS condition_variable
{
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
public:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
but The Standard declares it as
class condition_variable {
public:
condition_variable();
~condition_variable();
( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4849.pdf )
And condition_variable()
may throw.
Is libcxx incompatible with C++ Standard, or am I wrong?
An implementation is allowed to add noexcept
to a non-virtual function if it wont ever throw an exception, see [res.on.exception.handling]/5 of the C++17 standard (draft N4659).
However an implementation is not allowed to add constexpr
to a function. See [constexpr.functions]/1. See also LWG issue 2013.
std::condition_variable::condition_variable()
is specified as neither constexpr
, nor noexcept
, but there are no circumstances under which it must throw an exception. See [thread.condition.condvar].
So, noexcept
is fine, but constexpr
is not. However, functions being marked constexpr
that shouldn't be, is a common non-conformance. For example GCC declares math functions deliberately constexpr
although they are not supposed to be.