Login  Register

Re: Bug in Handle::operator==?

Posted by goetz.rienaecker on Jul 12, 2004; 3:01am
URL: http://quantlib.414.s1.nabble.com/Bug-in-Handle-operator-tp3035p3036.html

[hidden email] schrieb am 06.07.04 15:58:33:

>
> On 2004.06.16 14:23, [hidden email] wrote:
> > What now comes is may be a bug report:
> >
> > The operator== of a Handle is for example used by
> > Observer::unregisterWith(), where the observer has to find the
> > observable with which it wants to unregister.
> > I looked at the code and found:
> >
> > template <CLASS T>
> > inline bool Handle<T>::operator==(const Handle<T>& h) const {
> >   return (n_ == h.n_);
> > }
> >
> > As I understand, h.n_ is the reference count, not the pointer to the
> > object.
>
> Hi,
> the above is correct: h.n_ is a pointer to the integer holding  
> the reference count, not its value. Testing for equality of such  
> pointer is actually stricter than testing for equality of the pointers  
> to the object: in the first case, two handles are deemed equal only if  
> one of them is a copy of the other, while in the second case, all null  
> handles, however instantiated, would be considered equal.
>
> Later,
> Luigi
>

-- 

Hi Luigi,

Thank's for your answer - and I should apologize for the false alarm!
Actually I realized that my suspicion was wrong the same day I wrote the message and told the Admin that he may forget it.
Also, an error of this kind would probably have been observed much earlier.

But may be, I do have found a small bug now:
If ENABLE_ERROR_LINES is defined and Error::where() is used (e.g. in QL_ASSERT()), file and line are written into a C string 'char[100]', which causes memory violation for very long file names. Is there a reason why no std::string is used here?

Best,
Götz

---
Götz Rienäcker
mailto:[hidden email]