* Problem with template...
@ 2002-09-12 5:36 Jean-Sebastien Vachon
0 siblings, 0 replies; only message in thread
From: Jean-Sebastien Vachon @ 2002-09-12 5:36 UTC (permalink / raw)
To: gcc-help
Hi,
One of my co-worker has developped a template to instantiate a HashTable
and until recently everything was fine.
However, in the last few days he added a simple line (legitimate) that
cause all kind of problems on Linux but runs fine on Windows (I don't
know for other Unixes)
Here is the code...
template <class T_Key, class T_HashObj>
void HashTable<T_Key, T_HashObj>::Remove(T_Key oHKey, T_HashObj* poHObj)
{
int nHash = Hash(oHKey);
if (mpapoHashBuckets[nHash])
{
HashElement* poHsbl = NULL;
BucketObject* poDelete = NULL;
BucketObject* poCurrent =
(BucketObject *) mpapoHashBuckets[nHash]->GetHead();
while (poCurrent)
{
poDelete = poCurrent;
poHsbl = (HashElement *) poCurrent->GetObj();
poCurrent = poCurrent->GetNext();
if (poHsbl &&
mfEqualFnctn(poHsbl->GetKey(), oHKey) &&
poHsbl->GetHashObjRef() == poHObj)
{
mpapoHashBuckets[nHash]->Remove(poDelete);
HDelete poHsbl;
poHsbl = NULL;
mnHashObjs--; // <==== NEW LINE
}
}
}
}
I don't know why but when I step in the code down to this point and then
look at the execution step by step.. the new line is executed twice.
poCurrent starts with a valid pointer and poCurrent->GetNext() returns
NULL. The if (within the while) is executed as it should but when the
while condition is evaluated a second time, it jumps to NEW LINE before
exiting the function.
I tried reorganising the while loop but the problem is still there.
Any idea?
I am using GCC 3.1 on a i686-Linux (RedHat 7.2) system. The debugger I
used to step into the code is the latest release of GDB (5.2.1 installed
yerterday)
Thanks for you time.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-12 12:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-12 5:36 Problem with template Jean-Sebastien Vachon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).