[Bug debug/59171] New: pretty printers: reverse iterator off by one

jan.kratochvil at redhat dot com gcc-bugzilla@gcc.gnu.org
Mon Nov 18 12:58:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59171

            Bug ID: 59171
           Summary: pretty printers: reverse iterator off by one
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jan.kratochvil at redhat dot com
                CC: pmuldoon at redhat dot com, tromey at redhat dot com
            Target: x86_64-unknown-linux-gnu

(gdb) l 1
1    #include <vector>
2    int main() {
3      std::vector<int> vec;
4      vec.push_back(1);
5      std::vector<int>::reverse_iterator rbegin=vec.rbegin();
6      int rbegin_int=*rbegin;
7      std::vector<int>::reverse_iterator rend=vec.rend();
8      int rend_int=*rend; // undefined behavior, it may crash
9    }
(gdb) b 8
(gdb) r
(gdb) p rbegin
$1 = {<std::iterator<std::random_access_iterator_tag, int, long, int*, int&>> =
{<No data fields>}, current = 215}
(gdb) p rbegin_int
$2 = 1
(gdb) p rend
$3 = {<std::iterator<std::random_access_iterator_tag, int, long, int*, int&>> =
{<No data fields>}, current = 1}

Bug #1: Why it prints all the "{<std:... current =" stuff forward iterators do
not print?  reverse_iterator seems unimplemented to me.

Bug #2: the "current" value is off-by-one, reverse iterators point one item
_after_ the element they represent.  You see 'p rbegin' != 'p rbegin_int',
while 'p rend' prints what 'p rbegin' should have printed.



More information about the Gcc-bugs mailing list