•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,854 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,386 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 892 | Replies: 6
![]() |
•
•
Join Date: Feb 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi All,
I seem to be getting an error with my code when running Intel C++ compiler via Visual Studio 2005. The error generated is "Expression:map/set iterator not dereferencable"
I've given my code below in the hope that someone can spot the problem.
I seem to be getting an error with my code when running Intel C++ compiler via Visual Studio 2005. The error generated is "Expression:map/set iterator not dereferencable"
I've given my code below in the hope that someone can spot the problem.
C++ Syntax (Toggle Plain Text)
set<stl_index>::iterator eit1, eit2=elmt_ids.begin(); bool non_consecutive(false); // 0. checking whether the elements are consecutively numbered for ( eit2++, eit1=elmt_ids.begin(); eit1!=elmt_ids.end(); eit1++, eit2++ ) if ( (*eit1)+1 != (*eit2) ) { non_consecutive=true; break;
The only problem I can see with your code is that eit2 will overflow, being one step in front of eit1 each time. I can't see anything which looks like it should give a compiler error. Could you paste a more complete example of your code, since the actual problem may be elsewhere.
¿umop apisdn upside down? •
•
Join Date: Feb 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for that Bench. Unfortunately I probably didn't say it clearly enough but my code compiles ok but the problem crops up during debugging.... Since you picked up the overflow of eit2 any ideas on how I can improve my code.....
Once again Thanks for any help you can offer......
Once again Thanks for any help you can offer......
Last edited by tonylamb : Feb 9th, 2008 at 7:27 am.
In which case, the message may be telling you that you're attempting to de-reference the end() iterator (Which is actually 'one past the end'). To prevent the overflow problem, you might consider changing your loop terminating condition to
If eit1 is always one step behind eit2, then this check ought to ensure both iterators stay within the boundaries of elmt_ids begin/end range.
edit - fixed BB code tag
eit2!=elmt_ids.end() If eit1 is always one step behind eit2, then this check ought to ensure both iterators stay within the boundaries of elmt_ids begin/end range.
edit - fixed BB code tag
Last edited by Bench : Feb 9th, 2008 at 7:34 am.
¿umop apisdn upside down? •
•
Join Date: Feb 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks Bench it worked....I know I'm being a pain now but I new error surfaces during debug "Expression: deque subscript out of range" and the debugger points to the following bit of code... stl_index here is type unsignedint32..... I think alot of my problems are cropping up due to my novice status to OOC++
C++ Syntax (Toggle Plain Text)
stl_index nodes_per_element = plist[0].size(); deque<vector<stl_index> >::iterator it;
Last edited by tonylamb : Feb 9th, 2008 at 8:09 am.
it would appear that your
You might prefer to use the deque::at() function, which is bounds checked, and throws an out_of_range exception if you attempt to retrieve something from the deque which doesn't exist.
alternatively, you could check the element you're accessing against the size of plist
plist is empty at the point where your debugger has reached that portion of code.You might prefer to use the deque::at() function, which is bounds checked, and throws an out_of_range exception if you attempt to retrieve something from the deque which doesn't exist.
alternatively, you could check the element you're accessing against the size of plist
CPP Syntax (Toggle Plain Text)
if( 0 < plist.size() ) { stl_index nodes_per_element = plist[0].size(); deque<vector<stl_index> >::iterator it; //etc.
¿umop apisdn upside down? •
•
Join Date: Feb 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks again Bench....Sorry it took me a few days to respond. My PhD supervisor uses all the code files that I'm using but on Metrowerks Code Warrior and does not seem to have any issues. He believes I'm having problems becuse the Intel Compiler uses all the microsoft headers...... I'd welcome any comments or suggestions that you might have......
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Other Threads in the C++ Forum
- Previous Thread: Convert at System::String ^
- Next Thread: STL and threading


Linear Mode