﻿# 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:

```cpp
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:

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