[PATCH] __debug::list use C++11 direct initialization
François Dumont
frs.dumont@gmail.com
Thu Oct 18 05:38:00 GMT 2018
I've just reverted the controversial changes.
2018-10-18 François Dumont <fdumont@gcc.gnu.org>
   Partial revert.
   2018-10-08 François Dumont <fdumont@gcc.gnu.org>
   * include/debug/list (list<>::cbegin()): Use C++11 direct
   initialization.
   (list<>::cend()): Likewise.
   (list<>::erase(const_iterator, const_iterator)): Ensure consistent
   iterator comparisons.
   (list<>::splice(const_iterator, list&&, const_iterator,
   const_iterator)): Likewise.
   Partial revert.
   2018-10-15 François Dumont <fdumont@gcc.gnu.org>
   * include/debug/vector (vector<>::cbegin()): Use C++11 direct
   initialization.
   (vector<>::cend()): Likewise.
   (vector<>::insert(const_iterator, const _Tp&)): Use consistent
   iterator comparison.
   (vector<>::erase(const_iterator)): Likewise.
   (vector<>::erase(const_iterator, const_iterator)): Likewise.
François
On 10/17/2018 06:10 PM, Jonathan Wakely wrote:
> On 17/10/18 17:03 +0100, Jonathan Wakely wrote:
>> On 09/10/18 07:11 +0200, François Dumont wrote:
>>> Here is the communication for my yesterday's patch which I thought
>>> svn had failed to commit (I had to interrupt it).
>>>
>>> Similarly to what I've done for associative containers here is a
>>> cleanup of the std::__debug::list implementation leveraging more on
>>> C++11 direct initialization.
>>>
>>> I also made sure we use consistent comparison between
>>> iterator/const_iterator in erase and emplace methods.
>>>
>>> 2018-10-08 François Dumont <fdumont@gcc.gnu.org>
>>>
>>> Â Â Â * include/debug/list (list<>::cbegin()): Use C++11 direct
>>> Â Â Â initialization.
>>> Â Â Â (list<>::cend()): Likewise.
>>> Â Â Â (list<>::emplace<>(const_iterator, _Args&&...)): Likewise.
>>> Â Â Â (list<>::insert(const_iterator, initializer_list<>)): Likewise.
>>> Â Â Â (list<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
>>> Â Â Â (list<>::erase(const_iterator, const_iterator)): Ensure consistent
>>> Â Â Â iterator comparisons.
>>> Â Â Â (list<>::splice(const_iterator, list&&, const_iterator,
>>> Â Â Â const_iterator)): Likewise.
>>>
>>> Tested under Linux x86_64 Debug mode and committed.
>>>
>>> François
>>>
>>
>>> diff --git a/libstdc++-v3/include/debug/list
>>> b/libstdc++-v3/include/debug/list
>>> index 8add1d596e0..879e1177497 100644
>>> --- a/libstdc++-v3/include/debug/list
>>> +++ b/libstdc++-v3/include/debug/list
>>> @@ -521,15 +521,17 @@ namespace __debug
>>> Â Â Â Â // _GLIBCXX_RESOLVE_LIB_DEFECTS
>>> Â Â Â Â // 151. can't currently clear() empty container
>>> Â Â Â Â __glibcxx_check_erase_range(__first, __last);
>>> -Â Â Â for (_Base_const_iterator __victim = __first.base();
>>> +Â Â Â for (__decltype(__first.base()) __victim = __first.base();
>>
>> This change causes the regression.
>>
>> I think the problem is that the decltype is a reference, so every time
>> the loop does ++__victim it changes the iterator stored in __first.
>
>
> This would work:
>
> Â Â Â Â Â Â typedef typename __decltype(__first)::iterator_type _Base_iter;
> Â Â Â Â for (_Base_iter __victim = __first.base();
> Â Â Â Â Â Â Â Â __victim != __last.base(); ++__victim)
>
>
> Or simply:
>
> #if __cplusplus >= 201103L
> Â Â Â Â Â Â typedef _Base_const_iterator _Base_iter;
> #else
> Â Â Â Â Â Â typedef _Base_iterator _Base_iter;
> #endif
> Â Â Â Â for (_Base_iter __victim = __first.base();
> Â Â Â Â Â Â Â Â __victim != __last.base(); ++__victim)
>
>
> Or just restore the original code which worked fine!
>
> .
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_revert.patch
Type: text/x-patch
Size: 4099 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181018/735cd630/attachment.bin>
More information about the Libstdc++
mailing list