List iterators not equal - conditional agrees - if block is still entered

Hello,

I am searching a list to ensure duplicate elements are not added to it. I am not using a std::set because I don't want elements with the same key to overwrite one another - elements of a list may compare as equivalent without members of the elements being equivalent. Avoiding automatic assignment allows me to decide what to do next. Std::multiset is also not an option for my purposes.

This is C++. I'm writing code with Microsoft's Visual Studio 2008.

typedef boost::mutex MUTEX;
typedef boost::lock_guard<MUTEX> boost_guard;
typedef list<WorkUnit> WORK;

WORK::iterator temp;
WORK::iterator end;

boost_guard guardian(m_work_mtx);

end = this->m_lstWork.end();
temp = find(this->m_lstWork.begin(),end,wu);
if (temp == end);
{
this->m_lstWork.push_back(wu);

this->m_lstWork.sort();
}//end if

Using the Autos window while debugging I've verified temp is not equivalent to end at all times. The block section of the if-statement is always entered even as the conditional evaluates to false.

How is this happening? How might I correct what I am observing?
I've discovered there isn't anything mysterious going on. I made an error - but a subtle one.

Here is the condition of the if- statement:

if (temp == end);

Syntactically correctly but logically --- nonsensical. Notice the semicolon at the end of the conditional test. The conditional is evaluated but has no affect as I've told the compiler to do nothing regardless of the result.

Deleting the semicolon has the code behave in the expected manner. Lost a few hours to that one ^_^
Topic archived. No new replies allowed.