* doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document.
* doc/html/manual/using_macros.html: Regenerate.
* include/bits/c++config: Define _GLIBCXX_ASSERTIONS when
_GLIBCXX_DEBUG is defined. Disable std::string extern templates when
(_GLIBCXX_EXTERN_TEMPLATE, __glibcxx_assert): Depend on
_GLIBCXX_ASSERTIONS instead of _GLIBCXX_DEBUG.
* include/debug/debug.h [!_GLIBCXX_DEBUG]: Define
__glibcxx_requires_non_empty_range and __glibcxx_requires_nonempty.
* include/backward/auto_ptr.h (auto_ptr::operator*,
auto_ptr::operator->): Replace _GLIBCXX_DEBUG_ASSERT with
__glibcxx_assert.
* include/bits/basic_string.h (basic_string::operator[],
basic_string::front, basic_string::back, basic_string::pop_back):
Likewise.
* include/bits/random.h
(uniform_int_distribution::param_type::param_type,
uniform_real_distribution::param_type::param_type,
normal_distribution::param_type::param_type,
gamma_distribution::param_type::param_type,
bernoulli_distribution::param_type::param_type,
binomial_distribution::param_type::param_type,
geometric_distribution::param_type::param_type,
negative_binomial_distribution::param_type::param_type,
poisson_distribution::param_type::param_type,
exponential_distribution::param_type::param_type): Likewise.
* include/bits/regex.h (match_results::operator[],
match_results::prefix, match_results::suffix): Likewise.
* include/bits/regex.tcc (format, regex_iterator::operator++):
Likewise.
* include/bits/regex_automaton.tcc (_StateSeq::_M_clone): Likewise.
* include/bits/regex_compiler.tcc (_Compiler::_Compiler,
_Compiler::_M_insert_character_class_matcher): Likewise.
* include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise.
* include/bits/regex_scanner.tcc (_Scanner::_M_advance,
_Scanner::_M_scan_normal): Likewise.
* include/bits/shared_ptr_base.h (__shared_ptr::_M_reset,
__shared_ptr::operator*): Likewise.
* include/bits/stl_iterator_base_funcs.h (__advance): Likewise.
* include/bits/unique_ptr.h (unique_ptr::operator*,
unique_ptr::operator[]): Likewise.
* include/experimental/fs_path.h (path::path(string_type, _Type),
path::iterator::operator++, path::iterator::operator--,
path::iterator::operator*): Likewise.
* include/experimental/string_view (basic_string_view::operator[],
basic_string_view::front, basic_string_view::back,
basic_string_view::remove_prefix): Likewise.
* include/ext/random (beta_distribution::param_type::param_type,
normal_mv_distribution::param_type::param_type,
rice_distribution::param_type::param_type,
pareto_distribution::param_type::param_type,
k_distribution::param_type::param_type,
arcsine_distribution::param_type::param_type,
hoyt_distribution::param_type::param_type,
triangular_distribution::param_type::param_type,
von_mises_distribution::param_type::param_type,
hypergeometric_distribution::param_type::param_type,
logistic_distribution::param_type::param_type): Likewise.
* include/ext/vstring.h (__versa_string::operator[]): Likewise.
* include/std/complex (polar): Likewise.
* include/std/mutex [!_GTHREAD_USE_MUTEX_TIMEDLOCK]
(timed_mutex::~timed_mutex, timed_mutex::unlock,
(recursive_timed_mutex::~timed_mutex, recursive_timed_mutex::unlock):
Likewise.
* include/std/shared_mutex [!PTHREAD_RWLOCK_INITIALIZER]
(__shared_mutex_pthread::__shared_mutex_pthread,
__shared_mutex_pthread::~__shared_mutex_pthread): Likewise.
(__shared_mutex_pthread::lock, __shared_mutex_pthread::try_lock,
__shared_mutex_pthread::unlock, __shared_mutex_pthread::lock_shared,
__shared_mutex_pthread::try_lock_shared): Likewise.
(__shared_mutex_cv::~__shared_mutex_cv, __shared_mutex_cv::unlock,
__shared_mutex_cv::unlock_shared): Likewise.
(shared_timed_mutex::try_lock_until,
shared_timed_mutex::try_lock_shared_until): Likewise.
* include/std/valarray (valarray::valarray(const _Tp*, size_t),
valarray::operator=, valarray::sum, valarray::min, valarray::max,
_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT, _DEFINE_BINARY_OPERATOR):
Likewise.
From-SVN: r227595
+2015-09-09 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document.
+ * doc/html/manual/using_macros.html: Regenerate.
+ * include/bits/c++config: Define _GLIBCXX_ASSERTIONS when
+ _GLIBCXX_DEBUG is defined. Disable std::string extern templates when
+ (_GLIBCXX_EXTERN_TEMPLATE, __glibcxx_assert): Depend on
+ _GLIBCXX_ASSERTIONS instead of _GLIBCXX_DEBUG.
+ * include/debug/debug.h [!_GLIBCXX_DEBUG]: Define
+ __glibcxx_requires_non_empty_range and __glibcxx_requires_nonempty.
+ * include/backward/auto_ptr.h (auto_ptr::operator*,
+ auto_ptr::operator->): Replace _GLIBCXX_DEBUG_ASSERT with
+ __glibcxx_assert.
+ * include/bits/basic_string.h (basic_string::operator[],
+ basic_string::front, basic_string::back, basic_string::pop_back):
+ Likewise.
+ * include/bits/random.h
+ (uniform_int_distribution::param_type::param_type,
+ uniform_real_distribution::param_type::param_type,
+ normal_distribution::param_type::param_type,
+ gamma_distribution::param_type::param_type,
+ bernoulli_distribution::param_type::param_type,
+ binomial_distribution::param_type::param_type,
+ geometric_distribution::param_type::param_type,
+ negative_binomial_distribution::param_type::param_type,
+ poisson_distribution::param_type::param_type,
+ exponential_distribution::param_type::param_type): Likewise.
+ * include/bits/regex.h (match_results::operator[],
+ match_results::prefix, match_results::suffix): Likewise.
+ * include/bits/regex.tcc (format, regex_iterator::operator++):
+ Likewise.
+ * include/bits/regex_automaton.tcc (_StateSeq::_M_clone): Likewise.
+ * include/bits/regex_compiler.tcc (_Compiler::_Compiler,
+ _Compiler::_M_insert_character_class_matcher): Likewise.
+ * include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise.
+ * include/bits/regex_scanner.tcc (_Scanner::_M_advance,
+ _Scanner::_M_scan_normal): Likewise.
+ * include/bits/shared_ptr_base.h (__shared_ptr::_M_reset,
+ __shared_ptr::operator*): Likewise.
+ * include/bits/stl_iterator_base_funcs.h (__advance): Likewise.
+ * include/bits/unique_ptr.h (unique_ptr::operator*,
+ unique_ptr::operator[]): Likewise.
+ * include/experimental/fs_path.h (path::path(string_type, _Type),
+ path::iterator::operator++, path::iterator::operator--,
+ path::iterator::operator*): Likewise.
+ * include/experimental/string_view (basic_string_view::operator[],
+ basic_string_view::front, basic_string_view::back,
+ basic_string_view::remove_prefix): Likewise.
+ * include/ext/random (beta_distribution::param_type::param_type,
+ normal_mv_distribution::param_type::param_type,
+ rice_distribution::param_type::param_type,
+ pareto_distribution::param_type::param_type,
+ k_distribution::param_type::param_type,
+ arcsine_distribution::param_type::param_type,
+ hoyt_distribution::param_type::param_type,
+ triangular_distribution::param_type::param_type,
+ von_mises_distribution::param_type::param_type,
+ hypergeometric_distribution::param_type::param_type,
+ logistic_distribution::param_type::param_type): Likewise.
+ * include/ext/vstring.h (__versa_string::operator[]): Likewise.
+ * include/std/complex (polar): Likewise.
+ * include/std/mutex [!_GTHREAD_USE_MUTEX_TIMEDLOCK]
+ (timed_mutex::~timed_mutex, timed_mutex::unlock,
+ (recursive_timed_mutex::~timed_mutex, recursive_timed_mutex::unlock):
+ Likewise.
+ * include/std/shared_mutex [!PTHREAD_RWLOCK_INITIALIZER]
+ (__shared_mutex_pthread::__shared_mutex_pthread,
+ __shared_mutex_pthread::~__shared_mutex_pthread): Likewise.
+ (__shared_mutex_pthread::lock, __shared_mutex_pthread::try_lock,
+ __shared_mutex_pthread::unlock, __shared_mutex_pthread::lock_shared,
+ __shared_mutex_pthread::try_lock_shared): Likewise.
+ (__shared_mutex_cv::~__shared_mutex_cv, __shared_mutex_cv::unlock,
+ __shared_mutex_cv::unlock_shared): Likewise.
+ (shared_timed_mutex::try_lock_until,
+ shared_timed_mutex::try_lock_shared_until): Likewise.
+ * include/std/valarray (valarray::valarray(const _Tp*, size_t),
+ valarray::operator=, valarray::sum, valarray::min, valarray::max,
+ _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT, _DEFINE_BINARY_OPERATOR):
+ Likewise.
+
2015-09-07 Jonathan Wakely <jwakely@redhat.com>
* include/bits/shared_ptr_base.h (__shared_ptr::operator->): Change
detect violations of the requirements of the standard. This
is described in more detail in
<a class="link" href="ext_compile_checks.html" title="Chapter 16. Compile Time Checks">Compile Time Checks</a>.
+ </p></dd><dt><span class="term"><code class="code">_GLIBCXX_ASSERTIONS</code></span></dt><dd><p>
+ Undefined by default. When defined, enables extra error checking in
+ the form of precondition assertions, such as bounds checking in
+ strings and null pointer checks when dereferencing smart pointers.
</p></dd><dt><span class="term"><code class="code">_GLIBCXX_DEBUG</code></span></dt><dd><p>
Undefined by default. When defined, compiles user code using
the <a class="link" href="debug_mode.html" title="Chapter 17. Debug Mode">debug mode</a>.
+ When defined, <code class="code">_GLIBCXX_ASSERTIONS</code> is defined
+ automatically, so all the assertions enabled by that macro are also
+ enabled in debug mode.
</p></dd><dt><span class="term"><code class="code">_GLIBCXX_DEBUG_PEDANTIC</code></span></dt><dd><p>
Undefined by default. When defined while compiling with
the <a class="link" href="debug_mode.html" title="Chapter 17. Debug Mode">debug mode</a>, makes
</para>
</listitem></varlistentry>
+ <varlistentry><term><code>_GLIBCXX_ASSERTIONS</code></term>
+ <listitem>
+ <para>
+ Undefined by default. When defined, enables extra error checking in
+ the form of precondition assertions, such as bounds checking in
+ strings and null pointer checks when dereferencing smart pointers.
+ </para>
+ </listitem></varlistentry>
<varlistentry><term><code>_GLIBCXX_DEBUG</code></term>
<listitem>
<para>
Undefined by default. When defined, compiles user code using
the <link linkend="manual.ext.debug_mode">debug mode</link>.
+ When defined, <code>_GLIBCXX_ASSERTIONS</code> is defined
+ automatically, so all the assertions enabled by that macro are also
+ enabled in debug mode.
</para>
</listitem></varlistentry>
<varlistentry><term><code>_GLIBCXX_DEBUG_PEDANTIC</code></term>
element_type&
operator*() const throw()
{
- _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
+ __glibcxx_assert(_M_ptr != 0);
return *_M_ptr;
}
element_type*
operator->() const throw()
{
- _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
+ __glibcxx_assert(_M_ptr != 0);
return _M_ptr;
}
const_reference
operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_ASSERT(__pos <= size());
+ __glibcxx_assert(__pos <= size());
return _M_data()[__pos];
}
{
// Allow pos == size() both in C++98 mode, as v3 extension,
// and in C++11 mode.
- _GLIBCXX_DEBUG_ASSERT(__pos <= size());
+ __glibcxx_assert(__pos <= size());
// In pedantic mode be strict in C++98 mode.
_GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size());
return _M_data()[__pos];
reference
front() noexcept
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](0);
}
const_reference
front() const noexcept
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](0);
}
reference
back() noexcept
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](this->size() - 1);
}
const_reference
back() const noexcept
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](this->size() - 1);
}
#endif
void
pop_back() noexcept
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
_M_erase(size() - 1, 1);
}
#endif // C++11
const_reference
operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_ASSERT(__pos <= size());
+ __glibcxx_assert(__pos <= size());
return _M_data()[__pos];
}
{
// Allow pos == size() both in C++98 mode, as v3 extension,
// and in C++11 mode.
- _GLIBCXX_DEBUG_ASSERT(__pos <= size());
+ __glibcxx_assert(__pos <= size());
// In pedantic mode be strict in C++98 mode.
_GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size());
_M_leak();
reference
front()
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](0);
}
const_reference
front() const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](0);
}
reference
back()
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](this->size() - 1);
}
const_reference
back() const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
return operator[](this->size() - 1);
}
#endif
void
pop_back() // FIXME C++11: should be noexcept.
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
+ __glibcxx_assert(!empty());
erase(size() - 1, 1);
}
#endif // C++11
# endif
#endif
-// Macro for extern template, ie controling template linkage via use
+// Macro for extern template, ie controlling template linkage via use
// of extern keyword on template declaration. As documented in the g++
// manual, it inhibits all implicit instantiations and is used
// throughout the library to avoid multiple weak definitions for
namespace _GLIBCXX_STD_C { _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_END_NAMESPACE_CONTAINER \
_GLIBCXX_END_NAMESPACE_VERSION }
-# undef _GLIBCXX_EXTERN_TEMPLATE
-# define _GLIBCXX_EXTERN_TEMPLATE -1
#endif
#ifdef _GLIBCXX_PARALLEL
# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL
#endif
+// Debug Mode implies checking assertions.
+#ifdef _GLIBCXX_DEBUG
+# define _GLIBCXX_ASSERTIONS
+#endif
+
+// Disable std::string explicit instantiation declarations in order to assert.
+#ifdef _GLIBCXX_ASSERTIONS
+# undef _GLIBCXX_EXTERN_TEMPLATE
+# define _GLIBCXX_EXTERN_TEMPLATE -1
+#endif
+
// Assert.
-#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
+#if !defined(_GLIBCXX_ASSERTIONS) && !defined(_GLIBCXX_PARALLEL)
# define __glibcxx_assert(_Condition)
#else
namespace std
_IntType __b = std::numeric_limits<_IntType>::max())
: _M_a(__a), _M_b(__b)
{
- _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
+ __glibcxx_assert(_M_a <= _M_b);
}
result_type
_RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{
- _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
+ __glibcxx_assert(_M_a <= _M_b);
}
result_type
_RealType __stddev = _RealType(1))
: _M_mean(__mean), _M_stddev(__stddev)
{
- _GLIBCXX_DEBUG_ASSERT(_M_stddev > _RealType(0));
+ __glibcxx_assert(_M_stddev > _RealType(0));
}
_RealType
_RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_alpha > _RealType(0));
+ __glibcxx_assert(_M_alpha > _RealType(0));
_M_initialize();
}
param_type(double __p = 0.5)
: _M_p(__p)
{
- _GLIBCXX_DEBUG_ASSERT((_M_p >= 0.0) && (_M_p <= 1.0));
+ __glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0));
}
double
param_type(_IntType __t = _IntType(1), double __p = 0.5)
: _M_t(__t), _M_p(__p)
{
- _GLIBCXX_DEBUG_ASSERT((_M_t >= _IntType(0))
+ __glibcxx_assert((_M_t >= _IntType(0))
&& (_M_p >= 0.0)
&& (_M_p <= 1.0));
_M_initialize();
param_type(double __p = 0.5)
: _M_p(__p)
{
- _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0) && (_M_p < 1.0));
+ __glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0));
_M_initialize();
}
param_type(_IntType __k = 1, double __p = 0.5)
: _M_k(__k), _M_p(__p)
{
- _GLIBCXX_DEBUG_ASSERT((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
+ __glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
}
_IntType
param_type(double __mean = 1.0)
: _M_mean(__mean)
{
- _GLIBCXX_DEBUG_ASSERT(_M_mean > 0.0);
+ __glibcxx_assert(_M_mean > 0.0);
_M_initialize();
}
param_type(_RealType __lambda = _RealType(1))
: _M_lambda(__lambda)
{
- _GLIBCXX_DEBUG_ASSERT(_M_lambda > _RealType(0));
+ __glibcxx_assert(_M_lambda > _RealType(0));
}
_RealType
const_reference
operator[](size_type __sub) const
{
- _GLIBCXX_DEBUG_ASSERT( ready() );
+ __glibcxx_assert( ready() );
return __sub < size()
? _Base_type::operator[](__sub)
: _M_unmatched_sub();
const_reference
prefix() const
{
- _GLIBCXX_DEBUG_ASSERT( ready() );
+ __glibcxx_assert( ready() );
return !empty() ? _M_prefix() : _M_unmatched_sub();
}
const_reference
suffix() const
{
- _GLIBCXX_DEBUG_ASSERT( ready() );
+ __glibcxx_assert( ready() );
return !empty() ? _M_suffix() : _M_unmatched_sub();
}
const match_results<_Bi_iter, _Alloc>::char_type* __fmt_last,
match_flag_type __flags) const
{
- _GLIBCXX_DEBUG_ASSERT( ready() );
+ __glibcxx_assert( ready() );
regex_traits<char_type> __traits;
typedef std::ctype<char_type> __ctype_type;
const __ctype_type&
| regex_constants::match_not_null
| regex_constants::match_continuous))
{
- _GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
+ __glibcxx_assert(_M_match[0].matched);
auto& __prefix = _M_match._M_prefix();
__prefix.first = __prefix_first;
__prefix.matched = __prefix.first != __prefix.second;
_M_flags |= regex_constants::match_prev_avail;
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
{
- _GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
+ __glibcxx_assert(_M_match[0].matched);
auto& __prefix = _M_match._M_prefix();
__prefix.first = __prefix_first;
__prefix.matched = __prefix.first != __prefix.second;
auto& __ref = _M_nfa[__v];
if (__ref._M_next != _S_invalid_state_id)
{
- _GLIBCXX_DEBUG_ASSERT(__m.count(__ref._M_next) > 0);
+ __glibcxx_assert(__m.count(__ref._M_next) > 0);
__ref._M_next = __m[__ref._M_next];
}
if (__ref._M_has_alt())
if (__ref._M_alt != _S_invalid_state_id)
{
- _GLIBCXX_DEBUG_ASSERT(__m.count(__ref._M_alt) > 0);
+ __glibcxx_assert(__m.count(__ref._M_alt) > 0);
__ref._M_alt = __m[__ref._M_alt];
}
}
if (!_M_match_token(_ScannerT::_S_token_eof))
__throw_regex_error(regex_constants::error_paren);
__r._M_append(_M_pop());
- _GLIBCXX_DEBUG_ASSERT(_M_stack.empty());
+ __glibcxx_assert(_M_stack.empty());
__r._M_append(_M_nfa->_M_insert_subexpr_end());
__r._M_append(_M_nfa->_M_insert_accept());
_M_nfa->_M_eliminate_dummy();
_Compiler<_TraitsT>::
_M_insert_character_class_matcher()
{
- _GLIBCXX_DEBUG_ASSERT(_M_value.size() == 1);
+ __glibcxx_assert(_M_value.size() == 1);
_BracketMatcher<_TraitsT, __icase, __collate> __matcher
(_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits);
__matcher._M_add_character_class(_M_value, false);
// If matched, keep going; else just return and try another state.
case _S_opcode_backref:
{
- _GLIBCXX_DEBUG_ASSERT(__dfs_mode);
+ __glibcxx_assert(__dfs_mode);
auto& __submatch = _M_cur_results[__state._M_backref_index];
if (!__submatch.matched)
break;
case _S_opcode_accept:
if (__dfs_mode)
{
- _GLIBCXX_DEBUG_ASSERT(!_M_has_sol);
+ __glibcxx_assert(!_M_has_sol);
if (__match_mode == _Match_mode::_Exact)
_M_has_sol = _M_current == _M_end;
else
_M_results = _M_cur_results;
else // POSIX
{
- _GLIBCXX_DEBUG_ASSERT(_M_states._M_get_sol_pos());
+ __glibcxx_assert(_M_states._M_get_sol_pos());
// Here's POSIX's logic: match the longest one. However
// we never know which one (lhs or rhs of "|") is longer
// unless we try both of them and compare the results.
}
break;
default:
- _GLIBCXX_DEBUG_ASSERT(false);
+ __glibcxx_assert(false);
}
}
_M_scan_in_brace();
else
{
- _GLIBCXX_DEBUG_ASSERT(false);
+ __glibcxx_assert(false);
}
}
_M_token = __it->second;
return;
}
- _GLIBCXX_DEBUG_ASSERT(false);
+ __glibcxx_assert(false);
}
else
{
reset(_Tp1* __p) // _Tp1 must be complete.
{
// Catch self-reset errors.
- _GLIBCXX_DEBUG_ASSERT(__p == 0 || __p != _M_ptr);
+ __glibcxx_assert(__p == 0 || __p != _M_ptr);
__shared_ptr(__p).swap(*this);
}
typename std::add_lvalue_reference<_Tp>::type
operator*() const noexcept
{
- _GLIBCXX_DEBUG_ASSERT(_M_ptr != 0);
+ __glibcxx_assert(_M_ptr != 0);
return *_M_ptr;
}
{
// concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
- _GLIBCXX_DEBUG_ASSERT(__n >= 0);
+ __glibcxx_assert(__n >= 0);
while (__n--)
++__i;
}
typename add_lvalue_reference<element_type>::type
operator*() const
{
- _GLIBCXX_DEBUG_ASSERT(get() != pointer());
+ __glibcxx_assert(get() != pointer());
return *get();
}
typename std::add_lvalue_reference<element_type>::type
operator[](size_t __i) const
{
- _GLIBCXX_DEBUG_ASSERT(get() != pointer());
+ __glibcxx_assert(get() != pointer());
return get()[__i];
}
# define __glibcxx_requires_cond(_Cond,_Msg)
# define __glibcxx_requires_valid_range(_First,_Last)
-# define __glibcxx_requires_non_empty_range(_First,_Last)
# define __glibcxx_requires_sorted(_First,_Last)
# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
# define __glibcxx_requires_heap(_First,_Last)
# define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
-# define __glibcxx_requires_nonempty()
# define __glibcxx_requires_string(_String)
# define __glibcxx_requires_string_len(_String,_Len)
# define __glibcxx_requires_subscript(_N)
# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred)
# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred)
+#ifdef _GLIBCXX_ASSERTIONS
+// Verify that [_First, _Last) forms a non-empty iterator range.
+# define __glibcxx_requires_non_empty_range(_First,_Last) \
+ __glibcxx_assert(_First != _Last)
+// Verify that the container is nonempty
+# define __glibcxx_requires_nonempty() \
+ __glibcxx_assert(! this->empty())
+#else
+# define __glibcxx_requires_non_empty_range(_First,_Last)
+# define __glibcxx_requires_nonempty()
+#endif
+
#else
# include <debug/macros.h>
path(string_type __str, _Type __type) : _M_pathname(__str), _M_type(__type)
{
- _GLIBCXX_DEBUG_ASSERT(!empty());
- _GLIBCXX_DEBUG_ASSERT(_M_type != _Type::_Multi);
+ __glibcxx_assert(!empty());
+ __glibcxx_assert(_M_type != _Type::_Multi);
}
enum class _Split { _Stem, _Extension };
inline path::iterator&
path::iterator::operator++()
{
- _GLIBCXX_DEBUG_ASSERT(_M_path != nullptr);
+ __glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
- _GLIBCXX_DEBUG_ASSERT(_M_cur != _M_path->_M_cmpts.end());
+ __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
++_M_cur;
}
else
{
- _GLIBCXX_DEBUG_ASSERT(!_M_at_end);
+ __glibcxx_assert(!_M_at_end);
_M_at_end = true;
}
return *this;
inline path::iterator&
path::iterator::operator--()
{
- _GLIBCXX_DEBUG_ASSERT(_M_path != nullptr);
+ __glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
- _GLIBCXX_DEBUG_ASSERT(_M_cur != _M_path->_M_cmpts.begin());
+ __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin());
--_M_cur;
}
else
{
- _GLIBCXX_DEBUG_ASSERT(_M_at_end);
+ __glibcxx_assert(_M_at_end);
_M_at_end = false;
}
return *this;
inline path::iterator::reference
path::iterator::operator*() const
{
- _GLIBCXX_DEBUG_ASSERT(_M_path != nullptr);
+ __glibcxx_assert(_M_path != nullptr);
if (_M_path->_M_type == _Type::_Multi)
{
- _GLIBCXX_DEBUG_ASSERT(_M_cur != _M_path->_M_cmpts.end());
+ __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end());
return *_M_cur;
}
return *_M_path;
operator[](size_type __pos) const
{
// TODO: Assert to restore in a way compatible with the constexpr.
- // _GLIBCXX_DEBUG_ASSERT(__pos < this->_M_len);
+ // __glibcxx_assert(__pos < this->_M_len);
return *(this->_M_str + __pos);
}
front() const
{
// TODO: Assert to restore in a way compatible with the constexpr.
- // _GLIBCXX_DEBUG_ASSERT(this->_M_len > 0);
+ // __glibcxx_assert(this->_M_len > 0);
return *this->_M_str;
}
back() const
{
// TODO: Assert to restore in a way compatible with the constexpr.
- // _GLIBCXX_DEBUG_ASSERT(this->_M_len > 0);
+ // __glibcxx_assert(this->_M_len > 0);
return *(this->_M_str + this->_M_len - 1);
}
void
remove_prefix(size_type __n)
{
- _GLIBCXX_DEBUG_ASSERT(this->_M_len >= __n);
+ __glibcxx_assert(this->_M_len >= __n);
this->_M_str += __n;
this->_M_len -= __n;
}
_RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_alpha > _RealType(0));
- _GLIBCXX_DEBUG_ASSERT(_M_beta > _RealType(0));
+ __glibcxx_assert(_M_alpha > _RealType(0));
+ __glibcxx_assert(_M_beta > _RealType(0));
}
_RealType
else if (__dist == _Dimen * (_Dimen + 1) / 2)
_M_init_lower(__meanbegin, __meanend, __varcovbegin, __varcovend);
else
- _M_init_diagonal(__meanbegin, __meanend,
- __varcovbegin, __varcovend);
+ {
+ __glibcxx_assert(__dist == _Dimen);
+ _M_init_diagonal(__meanbegin, __meanend,
+ __varcovbegin, __varcovend);
+ }
}
param_type(std::initializer_list<_RealType> __mean,
_M_init_lower(__mean.begin(), __mean.end(),
__varcov.begin(), __varcov.end());
else
- _M_init_diagonal(__mean.begin(), __mean.end(),
- __varcov.begin(), __varcov.end());
+ {
+ __glibcxx_assert(__varcov.size() == _Dimen);
+ _M_init_diagonal(__mean.begin(), __mean.end(),
+ __varcov.begin(), __varcov.end());
+ }
}
std::array<_RealType, _Dimen>
result_type __sigma_val = result_type(1))
: _M_nu(__nu_val), _M_sigma(__sigma_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_nu >= result_type(0));
- _GLIBCXX_DEBUG_ASSERT(_M_sigma > result_type(0));
+ __glibcxx_assert(_M_nu >= result_type(0));
+ __glibcxx_assert(_M_sigma > result_type(0));
}
result_type
result_type __omega_val = result_type(1))
: _M_mu(__mu_val), _M_omega(__omega_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_mu >= result_type(0.5L));
- _GLIBCXX_DEBUG_ASSERT(_M_omega > result_type(0));
+ __glibcxx_assert(_M_mu >= result_type(0.5L));
+ __glibcxx_assert(_M_omega > result_type(0));
}
result_type
result_type __mu_val = result_type(1))
: _M_alpha(__alpha_val), _M_mu(__mu_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_alpha > result_type(0));
- _GLIBCXX_DEBUG_ASSERT(_M_mu > result_type(0));
+ __glibcxx_assert(_M_alpha > result_type(0));
+ __glibcxx_assert(_M_mu > result_type(0));
}
result_type
result_type __nu_val = result_type(1))
: _M_lambda(__lambda_val), _M_mu(__mu_val), _M_nu(__nu_val)
{
- _GLIBCXX_DEBUG_ASSERT(_M_lambda > result_type(0));
- _GLIBCXX_DEBUG_ASSERT(_M_mu > result_type(0));
- _GLIBCXX_DEBUG_ASSERT(_M_nu > result_type(0));
+ __glibcxx_assert(_M_lambda > result_type(0));
+ __glibcxx_assert(_M_mu > result_type(0));
+ __glibcxx_assert(_M_nu > result_type(0));
}
result_type
result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
- _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
+ __glibcxx_assert(_M_a <= _M_b);
}
result_type
result_type __omega = result_type(1))
: _M_q(__q), _M_omega(__omega)
{
- _GLIBCXX_DEBUG_ASSERT(_M_q > result_type(0));
- _GLIBCXX_DEBUG_ASSERT(_M_q < result_type(1));
+ __glibcxx_assert(_M_q > result_type(0));
+ __glibcxx_assert(_M_q < result_type(1));
}
result_type
_RealType __c = _RealType(1))
: _M_a(__a), _M_b(__b), _M_c(__c)
{
- _GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
- _GLIBCXX_DEBUG_ASSERT(_M_b <= _M_c);
- _GLIBCXX_DEBUG_ASSERT(_M_a < _M_c);
+ __glibcxx_assert(_M_a <= _M_b);
+ __glibcxx_assert(_M_b <= _M_c);
+ __glibcxx_assert(_M_a < _M_c);
_M_r_ab = (_M_b - _M_a) / (_M_c - _M_a);
_M_f_ab_ac = (_M_b - _M_a) * (_M_c - _M_a);
: _M_mu(__mu), _M_kappa(__kappa)
{
const _RealType __pi = __gnu_cxx::__math_constants<_RealType>::__pi;
- _GLIBCXX_DEBUG_ASSERT(_M_mu >= -__pi && _M_mu <= __pi);
- _GLIBCXX_DEBUG_ASSERT(_M_kappa >= _RealType(0));
+ __glibcxx_assert(_M_mu >= -__pi && _M_mu <= __pi);
+ __glibcxx_assert(_M_kappa >= _RealType(0));
auto __tau = std::sqrt(_RealType(4) * _M_kappa * _M_kappa
+ _RealType(1)) + _RealType(1);
result_type __n = 1)
: _M_N{__N}, _M_K{__K}, _M_n{__n}
{
- _GLIBCXX_DEBUG_ASSERT(_M_N >= _M_K);
- _GLIBCXX_DEBUG_ASSERT(_M_N >= _M_n);
+ __glibcxx_assert(_M_N >= _M_K);
+ __glibcxx_assert(_M_N >= _M_n);
}
result_type
result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
- _GLIBCXX_DEBUG_ASSERT(_M_b > result_type(0));
+ __glibcxx_assert(_M_b > result_type(0));
}
result_type
const_reference
operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
{
- _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
+ __glibcxx_assert(__pos <= this->size());
return this->_M_data()[__pos];
}
{
// Allow pos == size() both in C++98 mode, as v3 extension,
// and in C++11 mode.
- _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
+ __glibcxx_assert(__pos <= this->size());
// In pedantic mode be strict in C++98 mode.
_GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L
|| __pos < this->size());
inline complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta)
{
- _GLIBCXX_DEBUG_ASSERT( __rho >= 0 );
+ __glibcxx_assert( __rho >= 0 );
return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta));
}
public:
timed_mutex() = default;
- ~timed_mutex() { _GLIBCXX_DEBUG_ASSERT( !_M_locked ); }
+ ~timed_mutex() { __glibcxx_assert( !_M_locked ); }
timed_mutex(const timed_mutex&) = delete;
timed_mutex& operator=(const timed_mutex&) = delete;
unlock()
{
lock_guard<mutex> __lk(_M_mut);
- _GLIBCXX_DEBUG_ASSERT( _M_locked );
+ __glibcxx_assert( _M_locked );
_M_locked = false;
_M_cv.notify_one();
}
public:
recursive_timed_mutex() = default;
- ~recursive_timed_mutex() { _GLIBCXX_DEBUG_ASSERT( _M_count == 0 ); }
+ ~recursive_timed_mutex() { __glibcxx_assert( _M_count == 0 ); }
recursive_timed_mutex(const recursive_timed_mutex&) = delete;
recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
unlock()
{
lock_guard<mutex> __lk(_M_mut);
- _GLIBCXX_DEBUG_ASSERT( _M_owner == this_thread::get_id() );
- _GLIBCXX_DEBUG_ASSERT( _M_count > 0 );
+ __glibcxx_assert( _M_owner == this_thread::get_id() );
+ __glibcxx_assert( _M_count > 0 );
if (--_M_count == 0)
{
_M_owner = {};
else if (__ret == EPERM)
__throw_system_error(int(errc::operation_not_permitted));
// Errors not handled: EBUSY, EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
}
~__shared_mutex_pthread()
{
int __ret __attribute((__unused__)) = pthread_rwlock_destroy(&_M_rwlock);
// Errors not handled: EBUSY, EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
}
#endif
if (__ret == EDEADLK)
__throw_system_error(int(errc::resource_deadlock_would_occur));
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
}
bool
int __ret = pthread_rwlock_trywrlock(&_M_rwlock);
if (__ret == EBUSY) return false;
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
return true;
}
{
int __ret __attribute((__unused__)) = pthread_rwlock_unlock(&_M_rwlock);
// Errors not handled: EPERM, EBUSY, EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
}
// Shared ownership
if (__ret == EDEADLK)
__throw_system_error(int(errc::resource_deadlock_would_occur));
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
}
bool
// an exception.
if (__ret == EBUSY || __ret == EAGAIN) return false;
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
return true;
}
~__shared_mutex_cv()
{
- _GLIBCXX_DEBUG_ASSERT( _M_state == 0 );
+ __glibcxx_assert( _M_state == 0 );
}
__shared_mutex_cv(const __shared_mutex_cv&) = delete;
unlock()
{
lock_guard<mutex> __lk(_M_mut);
- _GLIBCXX_DEBUG_ASSERT( _M_write_entered() );
+ __glibcxx_assert( _M_write_entered() );
_M_state = 0;
// call notify_all() while mutex is held so that another thread can't
// lock and unlock the mutex then destroy *this before we make the call.
unlock_shared()
{
lock_guard<mutex> __lk(_M_mut);
- _GLIBCXX_DEBUG_ASSERT( _M_readers() > 0 );
+ __glibcxx_assert( _M_readers() > 0 );
auto __prev = _M_state--;
if (_M_write_entered())
{
if (__ret == ETIMEDOUT || __ret == EDEADLK)
return false;
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
return true;
}
if (__ret == ETIMEDOUT)
return false;
// Errors not handled: EINVAL
- _GLIBCXX_DEBUG_ASSERT(__ret == 0);
+ __glibcxx_assert(__ret == 0);
return true;
}
valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
: _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{
- _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
+ __glibcxx_assert(__p != 0 || __n == 0);
std::__valarray_copy_construct(__p, __p + __n, _M_data);
}
inline valarray<_Tp>&
valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
{
- _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz);
+ __glibcxx_assert(_M_size == __sa._M_sz);
std::__valarray_copy(__sa._M_array, __sa._M_sz,
__sa._M_stride, _Array<_Tp>(_M_data));
return *this;
inline valarray<_Tp>&
valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
{
- _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size());
+ __glibcxx_assert(_M_size == __ga._M_index.size());
std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
_Array<_Tp>(_M_data), _M_size);
return *this;
inline valarray<_Tp>&
valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
{
- _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz);
+ __glibcxx_assert(_M_size == __ma._M_sz);
std::__valarray_copy(__ma._M_array, __ma._M_mask,
_Array<_Tp>(_M_data), _M_size);
return *this;
inline valarray<_Tp>&
valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
{
- _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz);
+ __glibcxx_assert(_M_size == __ia._M_sz);
std::__valarray_copy(__ia._M_array, __ia._M_index,
_Array<_Tp>(_M_data), _M_size);
return *this;
inline _Tp
valarray<_Tp>::sum() const
{
- _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ __glibcxx_assert(_M_size > 0);
return std::__valarray_sum(_M_data, _M_data + _M_size);
}
inline _Tp
valarray<_Tp>::min() const
{
- _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ __glibcxx_assert(_M_size > 0);
return *std::min_element(_M_data, _M_data + _M_size);
}
inline _Tp
valarray<_Tp>::max() const
{
- _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ __glibcxx_assert(_M_size > 0);
return *std::max_element(_M_data, _M_data + _M_size);
}
inline valarray<_Tp>& \
valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \
{ \
- _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \
+ __glibcxx_assert(_M_size == __v._M_size); \
_Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \
_Array<_Tp>(__v._M_data)); \
return *this; \
typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \
- _GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
+ __glibcxx_assert(__v.size() == __w.size()); \
typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \