hyang51
hyang51

Reputation: 75

gdb vector attempt to take address not located in memory

I have a vector, vector<int> myvecotr. assume that myvector={p1,p2,p3,p4}, I need to read (p1, p2), (p2,p3),(p3,p4).

int t1,t2;
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end();++it){
   t1=*it;
   t2=*(it+1);   // the question is here ?
}

when I debug it using gdb,

(gdb) p *(it+1)
(gdb) Attempt to take address not located in memory  

so, my question is, why *(it+1),sometimes, doesn't work, but ++it works?

Any help will be greatly appreciated.

Upvotes: 3

Views: 5923

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22549

This is just a gdb bug, nothing more.

Upvotes: 6

Related Questions