Consider the following code :
void ListenerImpl::attach(boost::shared_ptr subscriber)
{
boost::unique_lock(mtx);
hmm.. I am not sure but can't this be protected against with normal c++ also?
class Mutex;
class Lock {
Lock(Mutex *mutex);
};
int main() {
Lock /* lock */ (&mtx);
return 0;
}
I get this compiler warning when compiling with DJGPP:
C:\df>gxx -c a.cpp
a.cpp: In function 'int main()':
a.cpp:8:30: error: 'mtx' declared as reference but not initialized
It compiles fine if I uncomment "lock" and add a mutex variable.
So if your "mtx" variable is a pointer. What happens if you change it and pass it as "&mtx" instead.