Hi Maik, On Tuesday 21 November 2006 22:11, Maik Justus wrote: > Hi Durk, > > I have added some cerr<<"..." to the source: > if (towerController->hasActiveTraffic()) > { > for (TrafficVectorIterator i = > towerController->getActiveTraffic().begin(); > i != towerController->getActiveTraffic().end(); i++) > { cerr << "a"; > if (i != current) { cerr << "b"; > //SGWayPoint curr (lon, > // lat, > // alt); > SGWayPoint other (i->getLongitude (), > i->getLatitude (), > i->getAltitude ()); > other.CourseAndDistance(curr, &course, &dist); > bearing = fabs(heading-course); > if (bearing > 180) > bearing = 360-bearing; > if ((dist < mindist) && (bearing < 60.0)) > { > mindist = dist; > closest = i; > minbearing = bearing; > otherReasonToSlowDown = true; > } > } cerr <<"c"; > } cerr<< "d"; > } > When the crash occur, a "a" is printed on the console. It's the first > time a "a" is printed, therefore it crashes, when this for-loop is > executed the very first time. And the only code between printing a "a" > and another letter is the (i != current) comparison > Then I modified the comparison to > if (i->getId() != current->getId()) > and every thing works fine.. After around 10 Minutes I get > abcdabcdabcdabcd........ on the console and no crash. > This means, that (i != current) compares (on msvc) not the pointers but > the objects entry by entry. I don't know why I was not successful by > adding a == operator. > > How can we force, that (i != current) compares pointers and not objects?
Thanks for taking your time to investigate. It seems like MSVC is doing something else than what gcc. I'm still a bit puzzled by this, because the i != current comparison is of the same class of operations in statements like the for() loop just above the code snippet you are citing. (i.e the for (TrafficVectorIterator i = towerController->getActiveTraffic().begin(); i != towerController->getActiveTraffic().end(); i++) loop. Apparently, these comparisons work as expected on the MSVC compiler. > > As a workaround I suggest to modify this comparison to if (i->getId() != > current->getId()) (and as well the comparisons in line 782 and 919) > Okay, that seems a reasonable request, which I can do, provided no ill side effects show up on my development box. Still, I'd be interested in the expert opinion of another C++ coder who's more familiar with MSVC than I am. Cheers, Durk ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel