aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/ext
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-09-09 18:12:47 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2015-09-09 18:12:47 +0100
commit2f1e8e7c4730bbc4bf15e85ecf4f954d1711db10 (patch)
tree9feeec2e2786095ed9ce8df4005ffb2e6e9c1e36 /libstdc++-v3/include/ext
parentc27348aaa59599eefacd930aba1a56978ca95281 (diff)
downloadgcc-2f1e8e7c4730bbc4bf15e85ecf4f954d1711db10.zip
gcc-2f1e8e7c4730bbc4bf15e85ecf4f954d1711db10.tar.gz
gcc-2f1e8e7c4730bbc4bf15e85ecf4f954d1711db10.tar.bz2
Enable lightweight checks with _GLIBCXX_ASSERTIONS.
* 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
Diffstat (limited to 'libstdc++-v3/include/ext')
-rw-r--r--libstdc++-v3/include/ext/random58
-rw-r--r--libstdc++-v3/include/ext/vstring.h4
2 files changed, 34 insertions, 28 deletions
diff --git a/libstdc++-v3/include/ext/random b/libstdc++-v3/include/ext/random
index 37bc732..be6db5d 100644
--- a/libstdc++-v3/include/ext/random
+++ b/libstdc++-v3/include/ext/random
@@ -415,8 +415,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
@@ -669,8 +669,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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,
@@ -688,8 +691,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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>
@@ -945,8 +951,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -1187,8 +1193,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -1420,8 +1426,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -1655,9 +1661,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -1893,7 +1899,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -2129,8 +2135,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -2364,9 +2370,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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);
@@ -2620,8 +2626,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _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);
@@ -2857,8 +2863,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -3114,7 +3120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 63349dd..94af25e 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -536,7 +536,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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];
}
@@ -555,7 +555,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// 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());