[ns] [bug] erase called on const_iterator

Frank Duerr frank.duerr at informatik.uni-stuttgart.de
Fri Feb 13 05:05:57 PST 2004


[Bug Report]

-----------------------------
Category:  Other
Package:   ns 2..27
OS:        Linux Red Hat  9
Environment Variables:
LD_LIBRARY_PATH=
TCL_LIBRARY=
TK_LIBRARY=


-----------------------------
Description:

In the method deque in file ns-2.27/common/scheduler-map.cc erase is called on a const_iterator. gcc will tolerate this, but for instance the Intel compiler icc8 for Linux does not compile this code because no erase method with const_iterator exists:

Event* MapScheduler::deque()
{
	EventQueue_t::const_iterator eIT = EventQueue_.begin();
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	if (eIT == EventQueue_.end()) 
		return 0;

	EventQueue_.erase(eIT);
        ^^^^^^^^^^^^^^^^^^^^^^^
	return *eIT;
}

Solution: Use a non-const iterator:

Event* MapScheduler::deque()
{
	EventQueue_t::iterator eIT = EventQueue_.begin();
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	if (eIT == EventQueue_.end()) 
		return 0;

	EventQueue_.erase(eIT);

	return *eIT;
}

How Easily Reproducible:
(e.g. every time, intermittent, once only, etc.)

Every time using the Intel compiler icc8 for Linux.





More information about the Ns-users mailing list