Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Sat, 29 Mar 2003 11:17:11 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Fred Ma cc: cygwin AT cygwin DOT com Subject: Re: gdb discrepancy in c++ iterators In-Reply-To: <3E8558BC.662C6DB3@doe.carleton.ca> Message-ID: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 29 Mar 2003, Fred Ma wrote: > Hello, > > I'm having the following problem only on cygwin, > not on solaris 8. I have a sanity-check program: > > #include > #include > using namespace std; > int main(void) > { > vector vi(3); > vector::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 = {> = > {}, _M_current = 0xc7e44589} > (gdb) p it_vi > $2 = {> = > {}, _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 Umm, you do know that calling vi.begin() will create a *new* iterator, right? As for it working on other systems, they may have different implementations of STL iterators. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk! -- /usr/games/fortune -- 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/