delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/03/29/03:31:06

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3E8558BC.662C6DB3@doe.carleton.ca>
Date: Sat, 29 Mar 2003 03:26:36 -0500
From: Fred Ma <fma AT doe DOT carleton DOT ca>
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: gnu.gcc.help,comp.unix.programmer
To: cygwin AT cygwin DOT com
Subject: gdb discrepancy in c++ iterators

Hello,

I'm having the following problem only on cygwin,
not on solaris 8.  I have a sanity-check program:

     #include<vector>
     #include<iostream>
     using namespace std;
     int main(void)
     {
        vector<int> vi(3);
        vector<int>::iterator it_vi = vi.begin();
        cout << "Hello world.";
     }

I compile it with gcc 3.2 use
gdb2003-03-03-cvs(cygwin-special) to view
vi.begin() and it_vi.  They are different:

     (gdb) p vi.begin()
     $1 = {<iterator<std::random_access_iterator_tag,int,int,int*,int&>> =
                 {<No data fields>}, _M_current = 0xc7e44589}
     (gdb) p it_vi
     $2 = {<iterator<std::random_access_iterator_tag,int,int,int*,int&>> =
                 {<No data fields>}, _M_current = 0xa041de0}

Why are they different?  If I actually dereference the iterators,
they contain the same thing.  But I want to deal with the iterators
themselves.  In particular, I want a conditional breakpoint to trigger
when it_vi==vi.begin()+4.  gdb won't let you add 4 to a random
access iterator, so I have to use the _M_current member data.
Since they are not the same above, I can't do that.  Thanks for
any light on why they differ.

Fred


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019