>
>
>
V1025. New variable with default value …


V1025. New variable with default value is created instead of 'std::unique_lock' that locks on the mutex.

The analyzer has detected an incorrect use of the 'std::unique_lock' class potentially leading to a race condition.

Consider the following example:

class C {
  std::mutex m_mutex;
  void foo() {
    std::unique_lock <std::mutex>(m_mutex);
  }
};

In this code, a new variable called 'm_mutex' is created and initialized to a default value. It means that the mutex will not be locked.

Fixed code:

void foo() {
  std::unique_lock <std::mutex> var(m_mutex);
}

This diagnostic is classified as: