Consider the following code :
void ListenerImpl::attach(boost::shared_ptr subscriber)
{
boost::unique_lock(mtx);
Compiler doesn't issue a warning, because it's quite possible that you might be updating some static-member / global
variable inside the constructor (which is valid and meaningful). e.g.:
struct A
{
static int count;
A () { count ++; }
};
Now when you simply invoke a temporary:
A();
In case if such update is not happening, compiler will not dig into the constructor of A
and check if something useful is happening. It always assumes to be a valid scenario. There are many such cases can be pointed out related to temporaries.