Opened 7 years ago

Closed 6 years ago

#11303 closed Bugs (duplicate)

boost::next(i,n) compilation error with -D_GLIBCXX_DEBUG

Reported by: pawels@… Owned by: No-Maintainer
Milestone: To Be Determined Component: utility
Version: Boost 1.58.0 Severity: Regression
Keywords: Cc: raad@…

Description

std::map provides bidirectional iterator while boost::next(i,n) tries to use the plus-assign which is random iterator specific.

% g++ -Wall gcc-bug.cpp -c -Og -isystem ~/dvm/sandbox/buildenv/boost-1.58.0/include -D_GLIBCXX_DEBUG
In file included from /usr/include/c++/4.9.2/debug/map.h:33:0,
                 from /usr/include/c++/4.9.2/debug/map:33,
                 from /usr/include/c++/4.9.2/map:66,
                 from gcc-bug.cpp:2:
/usr/include/c++/4.9.2/debug/safe_iterator.h: In instantiation of ‘__gnu_debug::_Safe_iterator<_Iterator, _Sequence>& __gnu_debug::_Safe_iterator<_Iterator, _Sequence>::operator+=(const difference_type&) [with _Iterator = std::_Rb_tree_iterator<std::pair<const int, int> >; _Sequence = std::__debug::map<int, int>; __gnu_debug::_Safe_iterator<_Iterator, _Sequence>::difference_type = long int]’:
/home/pawels/dvm/sandbox/buildenv/boost-1.58.0/include/boost/next_prior.hpp:73:11:   required from ‘static T boost::next_prior_detail::next_impl1<T, Distance, true>::call(T, Distance) [with T = __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<const int, int> >, std::__debug::map<int, int> >; Distance = int]’
/home/pawels/dvm/sandbox/buildenv/boost-1.58.0/include/boost/next_prior.hpp:151:67:   required from ‘T boost::next(T, Distance) [with T = __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<const int, int> >, std::__debug::map<int, int> >; Distance = int]’
gcc-bug.cpp:8:66:   required from here
/usr/include/c++/4.9.2/debug/safe_iterator.h:357:13: error: no match for ‘operator+=’ (operand types are ‘std::_Rb_tree_iterator<std::pair<const int, int> >’ and ‘const difference_type {aka const long int}’)
  _M_current += __n;
             ^

Attachments (2)

gcc-bug.cpp (234 bytes ) - added by anonymous 7 years ago.
bug.cpp (234 bytes ) - added by anonymous 7 years ago.
testcase

Download all attachments as: .zip

Change History (4)

by anonymous, 7 years ago

Attachment: gcc-bug.cpp added

by anonymous, 7 years ago

Attachment: bug.cpp added

testcase

comment:1 by raad@…, 7 years ago

Cc: raad@… added

comment:2 by Andrey Semashev, 6 years ago

Resolution: duplicate
Status: newclosed

Duplicates #10847.

Note: See TracTickets for help on using tickets.