diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2025-02-27 21:59:41 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2025-03-06 16:17:34 +0000 |
commit | 4412e9bb73754a0c9668e80c4b8ee2fefffbbb04 (patch) | |
tree | 61a06b6210efa23b86c523dc23e16044c97cd4d7 | |
parent | 88a521cc3283ae6b6bccc7afefe4723399ddb975 (diff) | |
download | gcc-4412e9bb73754a0c9668e80c4b8ee2fefffbbb04.zip gcc-4412e9bb73754a0c9668e80c4b8ee2fefffbbb04.tar.gz gcc-4412e9bb73754a0c9668e80c4b8ee2fefffbbb04.tar.bz2 |
libstdc++: Add assertions to std::list::pop_{front,back}
The recently-approved Standard Library Hardening proposal (P3471R4)
gives pop_front and pop_back member functions hardened preconditions,
but std::list was missing assertions on them. Our other sequence
containers do have assertions on those members.
libstdc++-v3/ChangeLog:
* include/bits/stl_list.h (list::pop_front, list::pop_back):
Add non-empty assertions.
Reviewed-by: Patrick Palka <ppalka@redhat.com>
-rw-r--r-- | libstdc++-v3/include/bits/stl_list.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index f987d8b..82ccb50 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -1784,7 +1784,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ void pop_front() _GLIBCXX_NOEXCEPT - { this->_M_erase(begin()); } + { + __glibcxx_requires_nonempty(); + this->_M_erase(begin()); + } /** * @brief Add data to the end of the %list. @@ -1833,7 +1836,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ void pop_back() _GLIBCXX_NOEXCEPT - { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); } + { + __glibcxx_requires_nonempty(); + this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); + } #if __cplusplus >= 201103L /** |