Extend usage of C++11 direct init in __debug::vector
Jonathan Wakely
jwakely@redhat.com
Wed Oct 17 15:57:00 GMT 2018
On 17/10/18 16:54 +0100, Jonathan Wakely wrote:
>On 15/10/18 07:23 +0200, François Dumont wrote:
>>This patch extend usage of C++11 direct initialization in
>>__debug::vector and makes some calls to operator - more consistent.
>>
>>Note that I also rewrote following expression in erase method:
>>
>>-Â Â Â Â return begin() + (__first.base() - cbegin().base());
>>+Â Â Â Â return { _Base::begin() + (__first.base() - _Base::cbegin()), this };
>>
>>The latter version was building 2 safe iterators and incrementing 1
>>with the additional debug check inherent to such an operation
>>whereas the new version just build 1 safe iterator with directly the
>>expected offset.
>>
>>2018-10-15 François Dumont <fdumont@gcc.gnu.org>
>>
>>Â Â Â * include/debug/vector (vector<>::cbegin()): Use C++11 direct
>>Â Â Â initialization.
>>Â Â Â (vector<>::cend()): Likewise.
>>Â Â Â (vector<>::emplace(const_iterator, _Args&&...)): Likewise and use
>>Â Â Â consistent iterator comparison.
>>Â Â Â (vector<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
>>Â Â Â (vector<>::insert(const_iterator, _InputIterator, _InputIterator)):
>>Â Â Â Likewise.
>>Â Â Â (vector<>::erase(const_iterator)): Likewise.
>>Â Â Â (vector<>::erase(const_iterator, const_iterator)): Likewise.
>>
>>Tested under Linux x86_64 Debug mode and committed.
>
>
>This test fails now:
>
>#define _GLIBCXX_DEBUG
>#include <list>
>
>int main()
>{
> std::list<int> l{11, 11, 11, 12, 12, 12, 13, 13, 13};
> auto m = std::next(l.begin(), 7);
> l.erase(l.begin(), m);
> if (l.size() != 2)
> throw 1;
>}
>
Sorry, I posted this in the wrong thread. Obviously it's the
<debug/list> patch in r264911 that caused the problem.
More information about the Libstdc++
mailing list