Login  Register

Bug in Handle::operator==?

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

Hi,

At first, thanks to all contributors to the great QuantLib project! The library is  plentiful source of object-oriented design in Quantitative Finance and already quite useful for practical pricing.

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.
This might cause, for instance, the observer to unregister from the wrong observable.

Probably, this mail comes a bit late because Handle will be replaced by boost::shared_pointer in the future, but I want to make sure if my observation was right.

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