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