mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Fixes #171 ("deque::clear() uses undefined behaviour")
This commit is contained in:
@@ -1341,6 +1341,8 @@ use [*Boost.Container]? There are several reasons for that:
|
|||||||
[section:release_notes_boost_1_76_00 Boost 1.76 Release]
|
[section:release_notes_boost_1_76_00 Boost 1.76 Release]
|
||||||
|
|
||||||
* Added [[no-discard]] attribute in all containers to catch bugs related to unused return values.
|
* Added [[no-discard]] attribute in all containers to catch bugs related to unused return values.
|
||||||
|
* Fixed bugs/issues:
|
||||||
|
* [@https://github.com/boostorg/container/issues/171 GitHub #171: ['"deque::clear() uses undefined behaviour"]].
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@@ -1843,6 +1843,8 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
|
|||||||
//! <b>Complexity</b>: Linear to the number of elements in the deque.
|
//! <b>Complexity</b>: Linear to the number of elements in the deque.
|
||||||
void clear() BOOST_NOEXCEPT_OR_NOTHROW
|
void clear() BOOST_NOEXCEPT_OR_NOTHROW
|
||||||
{
|
{
|
||||||
|
if (this->members_.m_finish != this->members_.m_start) {
|
||||||
|
|
||||||
for (index_pointer node = this->members_.m_start.m_node + 1;
|
for (index_pointer node = this->members_.m_start.m_node + 1;
|
||||||
node < this->members_.m_finish.m_node;
|
node < this->members_.m_finish.m_node;
|
||||||
++node) {
|
++node) {
|
||||||
@@ -1860,6 +1862,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
|
|||||||
|
|
||||||
this->members_.m_finish = this->members_.m_start;
|
this->members_.m_finish = this->members_.m_start;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Returns true if x and y are equal
|
//! <b>Effects</b>: Returns true if x and y are equal
|
||||||
//!
|
//!
|
||||||
|
Reference in New Issue
Block a user