interesting access violation

Started by
0 comments, last by Sammy0037 18 years, 8 months ago
Started debugging some new functions today. No compile errors but an access violation. After stepping through I found the offending line. Its a simple distance test that passes two locations and the radius of each object... one of the simpler forms of collision detection, right? So, I have pointers to the two objects, one from a std::list. Iterator = ObjectList.begin(); while ( Iterator != ObjectList.end() ) //'::Iterator' prototyped elswewhere { //-----The offending line is CollisionTest = CollisionDistance ( (*Iterator)->Location, Object->Location, (*Iterator)->Radius, pObject->Radius ); //--------------------------- ++Iterator }; //the collision function CollisionDistance(Vector &LocA, Vector &LocB, int RadiusA, int RadiusB) { //debugger exits here bool result; int DisSqrdX = (LocA.x - LocB.x) * (LocA.x - LocB.x); int DisSqrdY = (LocA.y - LocB.y) * (LocA.y - LocB.y); int RadiusSqrd = (RadiusA + RadiusB) * (RadiusA + RadiusB); (DisSqrdX + DisSqrdY < RadiusSqrd) ? result = true:result = false; return result; } (*iterator) is certainly different, so I suspect that. If I have them right, the iterators are dereferenced to the pointer values they hold. When passed, the values pointed to are received as references. However the error remains if received as simple values also. At least there are no compiler errors. Both values for 'Object' are defined according to the debugger. But all values in the iterator say the expression cannot be evaluated for all objects in the list. However I do not know if this is SOP when using the variables debug window, in that maybe it simply cannot access them. Well... at least I found where the problem was ;o) cheers
Advertisement
GRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR!!!!!!!!!!!!

Found it. I am happy to say that the iterator dereferencing seems to work just fine... at least no errors. I was using the wrong dumb-ass variable that has a similar name to the one that should have been there. I need to go back and rename a few things so this doesnt happen again. So much for trying to be efficient!

cheers!

This topic is closed to new replies.

Advertisement