c++iteratormultiset

c++ map/set iterator not dereferencable


I want to ask you for a hint, as I am a beginner and couldn't find any suitable answer in the internet. I am getting this error: debug assertion failed - map/set iterator not dereferencable at the line that looks like this:

pointA = active->pointNext(timeNext);

with the function pointNext() as I see everything is ok, and what concerns active, I have:

active = setS.data.end();

Some more info:

active is multiset< classA, classB::classC >::const_iterator

setS has: setS.Q, setS.W, setS.T and setS.data, whereby setS.data has inside 0 in square braces. When I have multiset iterator declaration in .cpp file, during debug I cannot enter to see what is inside active, when it is in .h file, I can.

Having in .cpp I cannot enter active, so can imagine it's like pointer(iterator) cannot dereference, because is wrong inside. What if it is empty, i.e. if setS.data is empty? or if there's some trash inside?

I know the thing was running under linux previously, is there some feature which I have to change for running on windows maybe? For example to change a number of template parameters to one only? (to properly ascribe setS.data to active, because I am not sure - do I do it properly?

Sorry for this rather chaotic post, I wanted to add my guesses for someone to neglect them if they are wrong. If something here is unclear or lack of some information, I will gladly add it. Can you please tell me what reasons could cause the dereferencablility error I get and where should I look for it? Because I am stuck and don't know how to proceed.

any help very appreciated, thanks!


Solution

  • Quite simply, since active points to the container's end(), you are not allowed to dereference it.

    I know the thing was running under linux previously

    If the code was exactly like this and was "running", all this means that the error has never manifested itself in a manner that you've noticed.