From dc9acaa99b9e6b3553f64b362cd22f32e961d3dc Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 19 Sep 2018 12:20:51 +0100 Subject: [PATCH] Don't use __glibcxx_assert to check class invariants Assertions should be used to check preconditions that users must meet, not to check whether the implementation is correct. * include/bits/regex_automaton.tcc (_StateSeq<_TraitsT>::_M_clone()): Remove __glibcxx_assert statements and use map::find instead of map::operator[]. From-SVN: r264422 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/bits/regex_automaton.tcc | 13 +++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 433bcdd4444..5911a297e96 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2018-09-19 Jonathan Wakely + + * include/bits/regex_automaton.tcc (_StateSeq<_TraitsT>::_M_clone()): + Remove __glibcxx_assert statements and use map::find instead of + map::operator[]. + 2018-09-18 François Dumont PR libstdc++/87135 diff --git a/libstdc++-v3/include/bits/regex_automaton.tcc b/libstdc++-v3/include/bits/regex_automaton.tcc index 7a0e6a36a7a..5993fcfeeaf 100644 --- a/libstdc++-v3/include/bits/regex_automaton.tcc +++ b/libstdc++-v3/include/bits/regex_automaton.tcc @@ -220,16 +220,9 @@ namespace __detail auto __v = __it.second; auto& __ref = _M_nfa[__v]; if (__ref._M_next != _S_invalid_state_id) - { - __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_assert(__m.count(__ref._M_alt) > 0); - __ref._M_alt = __m[__ref._M_alt]; - } + __ref._M_next = __m.find(__ref._M_next)->second; + if (__ref._M_has_alt() && __ref._M_alt != _S_invalid_state_id) + __ref._M_alt = __m.find(__ref._M_alt)->second; } return _StateSeq(_M_nfa, __m[_M_start], __m[_M_end]); } -- 2.30.2